Objective
To backup all users home directories to a separate hard drive.
To Schedule a cronjob to run the rsync script automatically.
rsync command used
rsync -av --progress --delete --log-file=/home/yourusername/rsync/$(date +%Y%m%d)_rsync.log /home /media/disk/backup
Ubuntu Linux
Need to modify the command slightly due to permission error failing the backup
rsync -av --progress --delete --log-file=/home/yourusername/rsync/$(date +%Y%m%d)_rsync.log --exclude "/home/your-username/.gvfs" /home /media/disk/backup
Multiple Home Directories
Rather than backup a single user home directory you can backup all user home directories by using *.
rsync -av --progress --delete --log-file=/home/yourusername/rsync/$(date +%Y%m%d)_rsync.log --exclude "/home/*/.gvfs" /home /media/disk/backup
Rsync Variables Explanation
-a = archive
v = increase verbosity
r = recursive: preserve the file timestamps and permission
--progress = shows progress during transfer
--delete = delete things from the remote rsync server that are also deleted locally
--log-file = output to a log file in the user directory /home/dragon/rsync and time stamp the file name with the year, month and day.
/home =start the backup in the /home directory
/media/disk/backup = the backup location disk must be mounted
First step
Create a new file called rsync.sh and open it for editing
At the top of the file insert #!/bin/bash
Copy the command above and insert underneath the above.
Save and exit
Second step
Right click rsync.sh left click Properties
go to the Permissions tab
Make the file executable by clicking the box Allow executing file as program
Close
Third Step
Copy rsync.sh to /etc/cron.daily (or another cron directory depending on the frequency you want to run it)
Fourth Step
Configure a cron job to run rsync.sh in /etc/cron.daily as root
No comments:
Post a Comment