Everyone knows it is a good idea to backup your data. However, the good ol' copy'n'paste routine is time consuming, inefficient, and prone to errors. By using rsync, you can achieve efficient synchronisation of files as only the change in data will be transferred.
For example, you might want to synchronise your home directory, /home/username/, to your external hard drive, /media/externalhdd/homebackup/. A oneliner is all that is needed:rsync -ra --progress --stats --log-file=rsynclog /home/username/ /media/externalhdd/homebackupThe options used are:For other options, do
- -r recursive (includes subfolders)
- -a archive (preserves, ownership, timestamps, etc.)
- --progress (shows progress of files being synchronised)
- --stats (print some statistics after synchronisation)
- --log-file=rsynclog (save useful information in file rsynclog in current directory)
rsync --helpYou can also use rsync for synchronisation to remote servers. If so, you may dorsync -ra --progress --size-only /home/username/ server.example.com:/home/username/homebackup/Note that such a connection to a remote server is insecure! You should be using SSH. Google it to find out how. One possible starting point is here.
Finally, you may want to use a script that runs at scheduled times to automate your backup process. An example script can be downloaded here (see below). Modify the script by removing the user input and use cron to run it at regular times, e.g., every night. rsyncbackup.sh
Thursday, June 26, 2008
How to synchronise files with rsync
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment