Blog

How to backup whole Linux server?

You can backup a whole VPS using the `rsync` command below.

rsync -avP --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/media/*","/lost+found"} / /mnt/hdd/encrypted/vps-server-backup/

You can also backup to other server.

rsync -avP --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/media/*","/lost+found"} / OTHER_SERVER_HERE:/mnt/hdd/encrypted/vps-server-backup/

You will first need to configure OTHER_SERVER_HERE in your ssh config file. You can check this for more info: https://linuxize.com/post/using-the-ssh-config-file/

You can add as many exclude parameters as you want. For example, if you want to exclude some special folder like: "/do/not/want/to/sync/this/folder/*". Please note the asterisk in the end.

You can do an encrypted backup too.
Just install encfs.
For example I did this for Ubuntu server.


apt-get update
apt-get install encfs

Now create the secure folder.

encfs /mnt/encrypted /mnt/decrypted
It will guide you through whole setup process. Its easy.

It will store encrypted filed in the /mnt/encrypted folder and so you will have to store all your files in /mnt/decrypted and use it like a normal folder. You will have to mount the /mnt/decrypted folder using the encfs again every time you restart your server. But, this time it will ask you just the password.

Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *