This is a question that i want to solve. This is a linux topic.
creating a scheduled task to create an incremental backup of our system files every day.
- Use the tar command
- Use the cpio command
- Use the dump command
Note: Files that have been changed to the day before
Advertisement
Answer
You can create a scheduled task using cron; to edit cron jobs, use crontab -e
(and maybe choose an editor, nano is very easy for beginners)
Add the following line to it:
0 1 * * * /path/to/backup/script
Meaning “at minute 0, hour 1, every day, every month, every day of week execute /path/to/backup/script.sh”
Explaining and posting a backup script is way to much for explaining here, but you can use any you find on google, e.g.: https://gist.github.com/arunk-s/10571807
That specific script will backup to a remove host via ssh, to store in a file simply replace line 38 with
tar --listed-incremental=$snap-1 -cvpz $sdir > "$ddir/$bfile"
and line 43 with
tar --listed-incremental=$snap -cvpz $sdir > "$ddir/full.$bfile"
Further information on how tar incremental backups work: https://www.gnu.org/software/tar/manual/html_section/tar_39.html
Further information on crontab: http://man7.org/linux/man-pages/man1/crontab.1.html
For backups I also recommend using LVM snapshots
– Create LVM snapshot and mount it
– Create backup of LVM snapshot
– Remove LVM snapshot
This way if some files are changed while backup is in process you will still get a persistent backup