Making Server Side Auto Back Up using Rsync on Debian 7

Kerjaan

Here I will writing the tutorial how to make auto back up using Rsync. First of all, all you need is sudo users, MTA (me, using exim4), and Rsync of course.

First, you need backup server users that login to produce server without using password. Here I will using id_rsa.pub keys.

  1. It’s no problem if you are using root user, but I chooses sudo user than root. The reason is security reason. I’m not allowing root user login. It easy to guess.

    Let say we are not using root user, we will make user who works special to do back up job.

    1. Create the user by entering the following command. Replace rsync with your desired username:
    2. Add the user to the administer the system (admin) group by entering the following command.
    3. On Debian 7 installations, you will need to install sudo before logging in as the new user:
    4. Log in to your VPS as the rsync by entering the following command.
  2. Now we have rsync user, we will make rsync as user who login to your production_server without password. Login as rsync user.

    1. On your backup_server, generate a passwordless SSH key by entering the following command. Press Return when prompted to enter a password – do not enter a password/passphrase.
    2. From your backup_server, copy the public key to your production_server by entering the following commands, one by one. The second line told you to rename uploaded_key.pub to authorized_keys. Use cd .ssh and ln -a command to find .ssh directory.
    3. Try connecting to your production_server from your backup_server by entering the following command:
      If you login successfully without password you are on the right way. Make sure this work well.
  3. Finally, we will create core backup strategy using Rsync. Rsync will backup your date incrementally, you haven’t to worry your data again.

    1. Install Rsync on both servers and exim4 on the backup_server by entering the following command:
    2. Create a directory to store your backups on your backup_server by entering the following command:
    3. Try creating a manual backup and storing it in ~/backups/public_orig/. This is the backup against which all future backups will be checked. From your backup_server, enter the following command:
      Here the explanation of Rsync command.
  4. We have to setup cron to do back up automatically. just type crontab -e and enter your job. Example:

I’m not going explain cronjob and database backup here. But if you want to learn it Linode Library is my recommendation.

See the log of your cron with this command:

Leave a Comment