Let's start .
Step 1:
saurabh@server:~$ mkdir linux_file_backup
saurabh@server:~$ cd linux_file_backup/
saurabh@server:~/linux_file_backup$ mkdir -p backup restore
saurabh@server:~/linux_file_backup$ ls
backup restore
saurabh@server:~/linux_file_backup$ cd backup/
saurabh@server:~/linux_file_backup/backup$ touch file{1..5}
saurabh@server:~/linux_file_backup/backup$ ls
file1 file2 file3 file4 file5
saurabh@server:~/linux_file_backup/backup$
Step 2:
Create snapshot-file :
- If you want to take incremental backup so we have to create snapshot file .
- It is used to incremental backup .
- If snapshot file exists , it's incremental backup otherwise it's a full backup.
- snapshot file is used to track what is changed ,It is keep record
saurabh@server:~/linux_file_backup$ tar -czvg snapshot-file -f 1-backup.tar.gz backup/
tar: backup: Directory is new
backup/
backup/file1
backup/file2
backup/file3
backup/file4
backup/file5
saurabh@server:~/linux_file_backup$ ls
1-backup.tar.gz backup restore snapshot-file
Step 3: Add new files and takes incremental backup
saurabh@server:~/linux_file_backup/backup$ ls
file1 file2 file3 file4 file5
saurabh@server:~/linux_file_backup/backup$ touch file{6..10}
saurabh@server:~/linux_file_backup/backup$ ls
file1 file10 file2 file3 file4 file5 file6 file7 file8 file9
saurabh@server:~/linux_file_backup$ tar -czvg snapshot-file -f 2-backup.tar.gz backup/
backup/
backup/file10
backup/file6
backup/file7
backup/file8
backup/file9
Check out Backup only which file add after 1 incremental
saurabh@server:~/linux_file_backup$ tar -tvf 1-backup.tar.gz
drwxrwxr-x saurabh/saurabh 36 2020-12-22 12:39 backup/
-rw-rw-r-- saurabh/saurabh 0 2020-12-22 12:39 backup/file1
-rw-rw-r-- saurabh/saurabh 0 2020-12-22 12:39 backup/file2
-rw-rw-r-- saurabh/saurabh 0 2020-12-22 12:39 backup/file3
-rw-rw-r-- saurabh/saurabh 0 2020-12-22 12:39 backup/file4
-rw-rw-r-- saurabh/saurabh 0 2020-12-22 12:39 backup/file5
saurabh@server:~/linux_file_backup$ tar -tvf 2-backup.tar.gz
drwxrwxr-x saurabh/saurabh 72 2020-12-23 18:03 backup/
-rw-rw-r-- saurabh/saurabh 0 2020-12-23 18:03 backup/file10
-rw-rw-r-- saurabh/saurabh 0 2020-12-23 18:03 backup/file6
-rw-rw-r-- saurabh/saurabh 0 2020-12-23 18:03 backup/file7
-rw-rw-r-- saurabh/saurabh 0 2020-12-23 18:03 backup/file8
-rw-rw-r-- saurabh/saurabh 0 2020-12-23 18:03 backup/file9
Restore incremental backup
saurabh@server:~/linux_file_backup$ ls
1-backup.tar.gz 2-backup.tar.gz backup restore snapshot-file
saurabh@server:~/linux_file_backup$ tar -xvf 1-backup.tar.gz -C restore/
backup/
backup/file1
backup/file2
backup/file3
backup/file4
backup/file5
saurabh@server:~/linux_file_backup/restore/backup$ ls
file1 file2 file3 file4 file5
saurabh@server:~/linux_file_backup/restore/backup$ cd ..
saurabh@server:~/linux_file_backup/restore$ cd .. saurabh@server:~/linux_file_backup$ tar -xvf 2-backup.tar.gz -C restore/
backup/
backup/file10
backup/file6
backup/file7
backup/file8
backup/file9
No comments:
Post a Comment