How to make a backup / backup in VPS with Rsync?
Learn how to make a backup on your Linux VPS using Rsync and SSH
Rsync is today the most powerful tool to perform backups and synchronizations to another server safely and freely in Linux. It is an application that works remotely and helps you transfer files efficiently. Today it is found for Unix-like and Microsoft Windows systems.
The main features of Rsync are:
* Copy links (shortcuts), devices, owners, groups and permissions.
* Does not require sudo privileges
* Data transfers are via pipelines to minimize latency costs.
By using rsync in linux, you will be able to transfer and synchronize both files and directories between a remote server and another server (external or your own pc).
On Debian and Ubuntu
apt-get install rsync
yum install rsync
External transfer method
Rsync can transfer via SSH , in which case the receiving server must also have Rsync. Like all applications with years of development there are many ways to use it Rsync on Wikipedia. Personally, the following has been very useful:
If you want to transfer a folder exclusively to another server using SSH:
rsync -vPa -e 'ssh -o StrictHostKeyChecking = no' /var /www /184.108.40.206:/var/www/
By adding the StrictHostKeyChecking parameter to the SSH connection, we will allow the introduction of the fingerprint to the .known_hosts file automatically.
In this case, we will be transferring the content of our /var /www /folder to the /var /www /folder contained within the server located at IP 220.127.116.11. When executing that instruction, if both servers allow SSH connections, it will ask for the destination server's password and progressively start copying data.
If you want to transfer a VPS to another VPS. Ideally both should understand the same Linux distribution, but experimenting a bit is not so necessary under the condition of excluding critical files and folders from the operation of the VPS:
You should create a text file with the paths to exclude in the data migration:
/boot /dev /tmp /sys /proc /backup /etc /fstab /etc /mtab /etc/mdadm.conf /etc /sysconfig /network *
You can name it excludes.txt
Later, as in case 1, we will call the same instruction but with an additional parameter (--exclude-from)
rsync -vPa -e 'ssh -o StrictHostKeyChecking = no' --exclude-from = /excludes.txt /18.104.22.168: /
Rsync is a very powerful tool for secure data migration. It is very important that both servers (remote and external) have rsync to be able to carry out this execution.
In our experience with VPS, working with this tool has been very satisfactory, allowing us to perform large data migrations with very little effort. It has more than a hundred options or lists of parameters that we invite you to discover and experiment.