Friday, April 11, 2008

Backup files to rsync server

There are days when I have to make sure that the laptop and PC files are backup file by file. If you have a server to hold all the files, it can be made into a networked backup server. There are many ways to do this but today I will write on the rsync server for CentOS 5.1 Linux.

The rsync does transfer of file by sending just the differences in the files across the link, without requiring that both sets of files are present at one of the ends of the link beforehand. At
first glance this may seem impossible because the calculation of diffs between two files normally requires local access to both files.

1. Setting up the rsync server
  1. Edit the file /etc/xinit.d/rsync where the yes is changed to no.
    disabled = no
  2. Restart the rsync service
    service rsync restart
    chkconfig rsync on
  3. Ensure that the firewall allows rsync through
  4. Ensure that clients can ssh to the server
2. Setting up the pc to send files to the rsync server at ip address 192.168.1.100
  1. Login to the localhost and open a terminal. Type the command

    rsync -avz --delete --timeout=999 -e ssh /home/nicholas/documents/ nicholas@192.168.1.100:/mnt/backup/

    1. -a is to archive
    2. -v is verbos
    3. -z is to compress
    4. -e is to use a secure SSH instead of rsh connection
    5. --delete to remove any files on server that does not exist locally

  2. Type the password for the user nicholas when requested for password.
3. Managing which files to be backed up
  1. To create a file to store the filter rules, open up a text editor. The format of the file is
    RULE FILENAME
    Where RULE + (plus) means include and - (minus) is exclude. An ** means include into sub directories. Example create a file called mylist.txt with the contents as below.

    + files.dir/
    + *.odt
    + **.ods

  2. To make rsync recursively find files in /home based on the rules in mylist.txt

    rsync -avz --exclude-from=mylist.txt --timeout=999 -e ssh /home nicholas@192.168.1.100:/mnt/backup

I will add more details on other aspects of rsync when I have more time. This includes public/private key pair and automated backup.

--

No comments: