Use tar and cron to regularly back up data-Linux Enterprise Application-Linux server application information. The following is a detailed description. Http://blog.fedorachina.cn/linux... using_tar_cron.html
I was shocked to accidentally delete a system configuration file under/etc! I am not used to setting alias rm = 'rm-I 'in bashrc, because it is annoying to delete many things. Although rm only deletes a file from an entry, the file is still on the disk and can be retrieved before it is overwritten by other data. But is it better to say "prevent it from burning?
In fact, I also seldom have the habit of backing up data. In the past, when I deleted the wrong stuff, I did not know how to think about it. In fact, it was quite useful to sum up and learn RHCE in the past, after all, the things I have summarized are much deeper. Now, I think it's natural to think of cron for periodic backup.
Although there are some very large and complex backup programs on Linux, it seems that tar + cron is enough for me. Some people say that Unix capabilities are the ability to use tools in combination. It doesn't make sense. In the Unix world, countless gadgets can be used with your confidence. You can't think of anything you can't do.
The following script uses the differential backup method to back up all data in/etc/Based on GNU tar and cron. A full backup is performed every Sunday. All the backups in the directory will be deleted before the full backup to save space. Differential backup is performed every other day of the week. The previous differential Backup will be deleted before the stabbed differential backup.
This script can naturally continue to be improved. For example, we can set aside the previous N backups. Each full backup and the differential Backup Based on it are placed in a moderate folder, but this is not done here. Some comments are in English, because they are in English. A large number of variables are used to facilitate modification, such as the backup location, backup time, and file name. If you need to modify the variables, the script body is not involved.
To use it, you can place the script anywhere and reference it in crontab. Note: You must run the script with the root permission, because files that require the root permission may appear in the directory to be backed up. For example, I put the script command backup. sh IN ~ /Bin/, so I can add the following content in crontab:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.