How to make a backup?
Backup is a very essential thing in any system, but it is not used as often as it should be. Data backup is necessary for the ability to quickly restore information. There are different ways to store backup files. In this article, we will consider "Cloud Data Storage".
This method allows you to store data on an external server. In case of system failure or other data loss reasons, you will always have a backup copy of the files.
You can also mount the network storage on the server or on another device. This will simplify your work with the backup copies of your data.
Content
We strongly recommend using the capabilities of a service like FairyDisk, as it will allow you to safely store your data without the risk of losing it.
FairyDisk is a fast and reliable cloud data storage where you can store not only backups, but also other important files. It is securely protected and will not allow anyone except you to access and steal information or your personal data.
When you go to the order page, you can change the 'Payment period' and 'Disk space'.
Mounting a network folder to your OS won't be difficult. You can find instructions in our knowledge base:
Guide to mounting a network drive on UNIX - Linux
Connecting a network drive to a Windows server - Windows
You can find more detailed information about this service on our website Fairyhosting.com
Also, you can always clarify any questions with our technical support, which will provide you with answers to all your inquiries.
After you have connected the network folder to your server, you need to perform the copying. How can this be done?
We will consider the backup process on the Ubuntu OS using the rsync utility.
To use rsync, it needs to be installed. The utility is installed using the following commands:
For Ubuntu, Debian:
# apt install rsync
For CentOS:
# yum install rsync
The rsync utility allows you to synchronize your files and directories another location. To create a backup, you need to enter the command in the command line of your server.
It looks like this:
# rsync -[options] [What exactly?] [Where?]
In this example, we have a mount point for a network resource in the /mount directory. For example, we want to backup the files of the server (directory /etc). The command will look like this:
rsync -aulv -x --progress /etc /mount
This process can be automated, and backups will be created automatically at the specified time.
crontab - is the utility that will help automate the creation of your backups. Use crontab -e to edit the user configuration. Enter the following in the command line:
# crontab -e
[min] [hour] [* - day of month] [month] [day of week]
"25 15 * * * bash /root/backup.sh" means that a backup will be created at 3:25 PM every day in the directory /root/backup.sh.
For a better understanding, we will provide three examples:
-
Backup will be created every day at 10:00 AM:
0 10 * * * bash /root/backup.sh
-
Backup will be created at 12:30 PM on the 1st day of every month:
30 12 1 * * bash /root/backup.sh
-
Backup will be created every week at 12:00 PM on Mondays:
0 12 * * 1 bash /root/backup.sh
To make everything work properly, you need to create a script, for this you need to go to the folder where the backups will be made.
# nano /root/backup.sh
And write the following code there.
!#/bin/bash/usr/bin/rsync -av -e ssh /etc /mount
The command means that the backup will be taken from /etc to /mount.
After the copying process is completed, you can go to the /mount directory and check the correctness of the created copy.
To restore, use the following command:
# rsync -aulv -x /mount/etc /
This means that we simply perform the previous command in reverse order, returning the files we need.