LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-06-2021, 06:38 PM   #1
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Rep: Reputation: 73
Back up folders over the local network


I need to back certain folders regularly from the new laptop to the old laptop.

Thanks to great help from LQ, I can do this easily like this:

Quote:
rsync -av -e "ssh" --progress /home/pedro/summer2021 pedro@192.168.10.13:/home/pedro/
At the moment, I copy and paste each command and press enter in bash, rsync asks for the password on the other laptop, then does the job.

But, since this is a recurring thing, I would like to automate it in bash.

How can I automate this process?

Make a text file with the paths to the folders to backup?

Then connect with ssh? Or still use rsync??

Can I hand rsync a batch file??
 
Old 04-06-2021, 07:15 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,764

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
You can still use rsync.

Use ssh keys and automate it using cron.

Last edited by michaelk; 04-06-2021 at 07:17 PM.
 
1 members found this post helpful.
Old 04-08-2021, 08:52 AM   #3
elgrandeperro
Member
 
Registered: Apr 2021
Posts: 415
Blog Entries: 2

Rep: Reputation: Disabled
I haven't used rsync in a while, but I believe this option:

--files-from=FILE read list of source-file names from FILE

Can be a file of directories to rsync. Since you are running cron, the path must be full (start with /)

So a file in your homedir called /home/pedro/RSYNCTHIS would be called like rsync -av --files-from=/home/pedro/RSYNCTHIS ...

have in RSYNCTHIS:

/home/pedro/summer2021
/home/pedro/otherthings
/home/pedro/mypics

etc.

As any rsync command, test it is always a good thing. Rsync often does unexpected things but this is pretty straightforward.
 
1 members found this post helpful.
Old 04-08-2021, 09:25 AM   #4
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,662

Rep: Reputation: Disabled
You can fire up rsync server (rsyncd), then there is no need to mount anything over network or create ssh connections.
 
1 members found this post helpful.
Old 04-08-2021, 04:07 PM   #5
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
Thank you all for the great tips!

I will try them, see if I can make it work. (Not too savvy with this stuff!)

I don't really want a cron job, I think, because this is something I do at odd times, Saturday morning, Sunday afternoon.

Mostly the old laptop is switched off, so I think cron wouldn't find it.
 
Old 04-08-2021, 04:31 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,764

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
Then automation is just writing a script that you can run as desired. Just need to use a bash script.

True, cron is really best for computers that run all the time but anacron jobs do not.
 
Old 04-08-2021, 09:13 PM   #7
elgrandeperro
Member
 
Registered: Apr 2021
Posts: 415
Blog Entries: 2

Rep: Reputation: Disabled
The reason I crontab is you don't have to think about it. It is rsync, if it fails you get it the next time. And you don't have to remember to run it. Now the downside, no revisions in time. But I usually use this to get the last good version which is generally good enough.
 
Old 04-08-2021, 09:23 PM   #8
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,662

Rep: Reputation: Disabled
rsnapshot, will save lots of space by using hard links.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What are the best ways and practices to manage local SSL certificates with my own CA, to get local HTTPS sites like https://testsite.local ? ZhaoLin1457 Slackware 11 02-04-2021 04:15 PM
[SOLVED] rsync keeps backing up same folders over and over coderlen Linux - Newbie 6 08-26-2019 02:14 PM
Shell Script to compare folders,Sub-Folders and Sub-Sub-Folders unix_72427 Programming 8 08-08-2012 02:51 PM
rsync keeps backing up same folders over and over Red Squirrel Linux - Server 9 01-04-2009 11:37 PM
Share folders with Windows machines over network furcatus Linux - Networking 2 12-08-2005 11:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration