LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Back up folders over the local network (https://www.linuxquestions.org/questions/linux-networking-3/back-up-folders-over-the-local-network-4175693235/)

Pedroski 04-06-2021 06:38 PM

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??

michaelk 04-06-2021 07:15 PM

You can still use rsync.

Use ssh keys and automate it using cron.

elgrandeperro 04-08-2021 08:52 AM

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.

Emerson 04-08-2021 09:25 AM

You can fire up rsync server (rsyncd), then there is no need to mount anything over network or create ssh connections.

Pedroski 04-08-2021 04:07 PM

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.

michaelk 04-08-2021 04:31 PM

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.

elgrandeperro 04-08-2021 09:13 PM

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.

Emerson 04-08-2021 09:23 PM

rsnapshot, will save lots of space by using hard links.


All times are GMT -5. The time now is 12:18 PM.