How to Use Tar for Differential Backup in Linux?

Source: Internet
Author: User
Keywords tar differential backup differential backup
To be honest, I have been backing up files manually over the years, and every time it’s a full backup. In fact, I knew that there was incremental backup a long time ago. Maybe I’m not used to it, or it’s always a full backup. . Today, I will record some experience of tar's differential backup and incremental backup.
Simple Application Server
USD1.00 New User Coupon
* Only 3,000 coupons available.
* Each new user can only get one coupon(except users from distributors).
* The coupon is valid for 30 days from the date of receipt.

Let me first talk about how to make a complete backup
tar -czvf filename.tgz filename
This is a normal packaging command, nothing special, let's use a -g parameter
tar -g snapshot -czvf filename.tgz filename

After the execution is complete, a snapshot file will be generated, which records the backup information.

Insert a dividing line here to talk about incremental backup and differential backup.

If we want to perform incremental backups, then this snapshot needs to be updated all the time. After each increment, the snapshot file will change. If we need to restore, we need to restore all incremental backups and full backups together.

If we want to perform a differential backup, then we need to protect this snapshot, and then do an incremental backup for the full backup each time, then when restoring, we only need to restore the last incremental backup and the full backup together.

Advantages and disadvantages: Incremental backup takes up less space than differential backup, but it is very troublesome to restore, especially if you only do a full backup in a month, and only do incremental backups every day, then you have to restore many incrementals when restoring backup file.

Differential backup occupies more space than incremental backup, but if the backup file is modified less, the file of differential backup will not be too large. When restoring, only full backup and differential backup need to be restored, and the workload will be much smaller. .

Well, back to the topic, we will talk about differential backup here. There are a bunch of references on the Internet for incremental backup, so I won't introduce it.
cp snapshot snapshot.backup
tar -g snapshot -czvf filename-1.tgz filename
mv snapshot snapshot-1.backup
cp snapshot.backup snapshot
In this way, we have recorded the change information of this differential backup in snapshot-1.backup, and then the differential backup file is filename-1.tgz

If there is a soft link in the file or directory we want to back up, and we need to back up the source file of the file or directory corresponding to the soft link, we need to add a -h attribute
tar -czvhf filename.tgz filename
View the contents of the tgz file
tar -tvf filename.tgz

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.