Entire file system data backup in Linux Server

Backup

Entire file system data backup in Linux Server

Here I am mentioning the things need to taken care while entire file system data backup on a linux server in web hosting industry using rsync to another location. Mainly this needed when we perform a full server migration and we may need to keep the old server data for some days for reference. In that case we can take a mirror copy of the entire files sytem to a backup location. While doing the backup of entire file system, we need to exclude some partitions like “/proc”, “/dev”, “/sys”.

Details of excluding file systems

Both /proc and /sys are virtual filesystems which reflect the state of the system, and allow you to change several runtime parameters (and sometimes do more dangerous things, like directly writing to the memory or to a device). You should never backup or restore them.

In most modern distributions, /dev is dynamically created at boot. There is no point in backing it up, and attempting to restore it is futile. However, if your distribution is configured to use a static /dev, this does not apply.

Even if you are after a full system restore, then it you could omit /proc, /boot & /dev. Then you can install the minimum OS from your boot media and then restore your system via your backup.

If you will rebuild then you only need the configuration/data files for your services (eg: /etc, /opt, /var, /home).

Some other directories we can exclude to avoid issues.

cagefs-skelton

CageFS creates a filesystem template in /usr/share/cagefs-skeleton directory. CageFS template will be mounted for each customer. There is no need to copy this directory while taking the backup of the entire linux server.

Virtfs

cPanel & WHM uses VirtFS to provide a jailed shell environment for users who connect to a server via SSH. The jailed shell acts as a container for the user, and does not allow the user to access other users’ home directories on the server.

We can avoid virtfs too from the rsync backup.

/backup

There is no need to add backup to backup, it will be wastage of time.

A sample command to do the rsync backup excluding the above mentioned directories.

rsync -avz --exclude=/backup/ --exclude=/proc/ --exclude=/sys/ --exclude=/dev/ --exclude=/home/cagefs-skeleton/ --exclude=/usr/share/cagefs-skeleton/ --exclude=/home/virtfs/ --progress / root@IP_ADDRESS:/backup/IP_ADDRESS/

Explanation

-a			archive mode
-v 			By default, rsync works silently. 
                        A single -v will give you information about what  files are being transferred 
                        and a brief summary at the end.
-z			compress file data during the transfer
--exclude=PATTERN       exclude files matching PATTERN
--progress		show progress during transfer
About Suhesh KS 24 Articles
Mr. Suhesh KS is Linux System Administrator by profession with 11 Years of work experience in Linux system administration in web hosting, data center and data warehousing industry and have worked with reputed support companies. He has wide range of skills include team management, system administration ( Linux ), programming ( bash, perl, php, java ), web hosting, data center support, seo analysis.