We often use TAR to backup files to tape to make full backup or using ctime or atime for creating new file names. But while your files are getting larger, let's say apache, logs or any file that modifies from time to time you need to have incremental backups. Incremental backups let's you backup only the files/folder that are modified within the specified time range. To increment the backup, you need this unix command.
tar -cvz --file=/path/to/backupfile.tgz --listed-incremental=/path/to/folder/snar /path/to/backup
- thus, -cvz = create,verbose,gzip
- --file= your backup destination e.g. /home/dijae/backup.tar.gz
- --listed-incremental = this is the key to our incremental backup. During a `--create' operation, specifies that the archive that `tar' creates is a new GNU-format incremental backup, using SNAPSHOT-FILE to determine which files to backup. With other operations, informs `tar' that the archive is in incremental format. *Note Incremental Dumps::.
For our example:
- backup target = /var/www/wordpress
- backup destination = /opt/backup
- snapshot file = /var/log/snar
So our command should be:
[root@localhost]# tar -cvz --file=/opt/backup/backup.tgz --listed-incremental=/var/log/snar /var/www/wordpress
Let's also make another file with a filename of "date"
just add: `date +%F` this will display YYY-MM-DD format
[root@localhost] # tar -cvz --file=/opt/backup/`date +%F`.backup.tgz --listed-incremental=/var/log/snar /var/www/wordpress
To restore:
- copy the all your backup.tgz to a new folder
- extract by: tar -xvz --file=/backup/file.tgz --listed-incremental=/dev/null
0 comments:
Post a Comment