Differential backup for delete and restoring files and folders

15 Views Asked by At

Differential backup copies only the newly added data from the last full back.Everytime a new backup gets created, it'll always compare with initial backup.

Working Scenario

  1. We are taking a initial backup for dir 20231229
tar --verbose --create --file 20231229_0.tar --listed-incremental=20231229_0.snar 20231229
  1. Add a new file in the dir (20231229)
touch 20231229/new_file_2.txt
  1. Copy the snapshot file
cp 20231229_0.snar 20231229_1.snar
  1. Create a first backup
tar --verbose --create --file 20231229_1.tar --listed-incremental=20231229_1.snar 20231229

-rw-r-----.  1 user user 551M Mar 28 07:23 20231229_0.tar
-rw-r-----.  1 user user 6.6K Mar 28 07:23 20231229.snar
-rw-r-----.  1 user user 7.9M Mar 28 07:26 20231228_1.tar
-rw-r-----.  1 user user 6.6K Mar 28 07:26 20231229_1.snar

Works fine here..

But after creating first full backup, if i delete the directory and then restore the directory using tar, and then when i try to do the first backup, it's creating the full backup again..

Non Working Scenario

Eg:-

  1. Initial backup
tar --verbose --create --file 20231229_0.tar --listed-incremental=20231229_0.snar 20231229
  1. Delete source directory 20231229.
  2. Restore source directory using 20231229_0.tar
tar --directory=/data/Vasanth/ --extract --verbose --file=20231229_0.tar --listed-incremental=/dev/null
  1. Copy the snapshot file
cp 20231229_0.snar 20231229_1.snar
  1. Create a first backup tar --verbose --create --file 20231229_1.tar --listed-incremental=20231229_1.snar 20231229
-rw-r--rw-. 1 user user 551M Mar 28 11:04 20231229_0.tar
-rw-r--rw-. 1 user user 6.6K Mar 28 11:04 20231229_0.snar
-rw-r--rw-. 1 user user 551M Mar 28 11:19 20231229_1.tar
-rw-r--rw-. 1 user user 6.5K Mar 28 11:19 20231229_1.snar

Since the directory is deleted and restored (eventhough it has same timestamps after restoring),when creating the first backup, its creating full backup again.

Any solution to avoid this creating again full backup, after restoring?

0

There are 0 best solutions below