How to create a Backup System using scp and rsync.

Linux-LogoBackup is a most important job for a Linux Server Admin. Everyday we have to backup our application and database from remote server. In this article I will provide a basic way to keep backup of your application and database.


System Information:

Full Backup:

For taking full backup we need to follow some basic steps. Create a directory in both servers.

Create a gzip archive file yourapp.tar.gz

If you have multiple applications and want to keep backup of them then issue the below command.

In my previous post I already shared how to backup MySQL db’s

Now we will transfer our backup copies to another remote server.

In this article I will use password less SSH login to transfer files to other server using SSH.

On application server i.e issue the below commands

It will create two files at ~/.ssh/ folder

We have to copy the public key to our backup server i.e. for password less login.

Now we will copy the backup file to our backup server.

The above command will copy the latest file from the backup folder.

Incremental Backup:

For incremental bakcup we have to use rsync command like below

On backup server create a folder:

Issue this command on application server.

Finally you have to add the below commands on server corntab to automate the backup policy.

Also you have to add the MySQL bakcup script over here in the cronjob:

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

Leave a Reply