Friday, 12 August 2022

Linux: Experiment on incremental FS backup using tar

    Incremental backup using tar : good for file system backup/archiving of log directories etc. 


Commands: I am using LVL variable to ease my work in rewriting incremental backup. Start from 0 and go up from there.

export LVL=0

tar --verbose --create --file=tmp_${LVL}.tar --listed-incremental=tmp.snar tmp/*

Note: snar file remains same at all levels, it is the tracker for incremental changes.

Next just change LVL=1,2 ..... so on. Must or the tar file get overwritten.



If any of the files get changed or new file created, next level automatically picks it up.


Alternate Method(I prefer):See the variable --level (0 means base and the incrementals)

export LVL=1

tar --verbose --create --file=tmp_${LVL}.tar --listed-incremental=tmp.snar --level=${LVL} tmp/*





Note: Extracting tar is same as before, tar xvf in the order it was backed up.