Backup/Restore user home dir using a script

Backup/restore can be as simple as a one line script. I prefer tar(1), so this shows both backup/restore of /home:
# cd / && tar -cf- home > "file or device"
restore of /home:
# cd / && tar -xf- < "file or device"


Now depending how/were this data is physically stored, I usually pipe it through ccrypt. Example:
# cd / && tar -cf- home | ccencrypt -k "keyfile" > "file or device"
of course make sure you keep the "keyfile" secret. Note, you can also add a pipe through one of the compression utilities, example: gzip(1).

John
 
  • Thanks
Reactions: ccc
I'm also looking for a backup script that will allow me to use dump on a weekly basis to backup my entire root file system, put the date in the filename and then have 4 weekly backups (so after the 5th week the first file is overwritten). Is this easily accomplished with a script and a cron job?
 
xy16644 said:
Is this easily accomplished with a script and a cron job?

Yes it is. I don't see any problem here, except if you are backing up the / you will have recursion on the backup itself. Anyway, use date(1) to get the date (i-th day) and append it to a string that will be the filename, then tar(1) against such file. Place all in cron and it is done.
 
Back
Top