C++Guns – RoboBlog

27.04.2015

rsync cron ssh - daily compressed remote backup

Filed under: Allgemein — Tags: — Thomas @ 12:04

Add user
Add user on you lokal and remote host. Disable password auth on your remote host:
# adduser --disabled-password user

Create authentication keys on your lokal machine
$ ssh-keygen -t rsa

Copy user/.ssh/id_rsa.pub to the end of remote host user/.ssh/authorized_keys

rsync command
-h humand readable
-P show progress
-a archive mode
-v verbode
-z compress
-e using ssh

sync --stats -hPavze ssh /home/user user@remotehost:/home/user/daily

lokal cron command
Put this in an extra file in /etc/cron.d/
Calls rsync with username user daily at 10:01pm
The current date, standard and error output from rsync is redirected to cronlog file.

1 22 * * * user date >> /home/buchhaltung/cronlog; rsync --delete --stats -hPavze ssh /home/user user@remotehost:/home/user/daily >> /home/user/cronlog 2>&1

remote cron command
Put this in an extra file in /etc/cron.d/
Make a compressed backup every day at 11:01pm
1 23 * * * user tar -cvjf /home/user/dailybackup/daily_$(date +%Y%m%d).tar.bz2 /home/user/daily/

usefull links
http://www.marksanborn.net/howto/use-rsync-for-daily-weekly-and-full-monthly-backups/
http://www.marksanborn.net/linux/learning-cron-by-example/
http://www.linuxproblem.org/art_9.html

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress