Re: Home made backup system
Thanks to all who replied!
This script (or elements of it) looks useful to me, but I don't fully
understand it -- I plan to work my way through it -- I have a few questions
now, I'm sure I will have more after I get past the first 3 (or more
encouraging to me, first 6) lines.
Questions below:
On Wednesday, December 18, 2019 12:26:04 PM tomas@tuxteam.de wrote:
> On Wed, Dec 18, 2019 at 12:02:56PM -0500, rhkramer@gmail.com wrote:
> #!/bin/bash
> home=${HOME:-~}
What does that line do, or more specifically, what does the :-~ do -- note the
following:
rhk@s19:/rhk/git_test$ echo ${HOME:-~}
/home/rhk
rhk@s19:/rhk/git_test$ echo ${HOME}
/home/rhk
> if test -z "$home" -o \! -d "$home" ; then
What does the -o \! do -- hmm, I guess \! is a bash "refeence" to the owner --
I guess I should look for it in man bash...
Hmm, but that means (in bash) the "history number" of the command
" \! the history number of this command"
> echo "can't backup the homeless, sorry"
> exit 1
> fi
I'm sure I'll have more questions as I continue, but that is enough for me for
tonight.
> backup=/media/backup/${home#/}
> rsync -av --delete --filter="merge $home/.backup/filter" $home/ $backup/
> echo -n "syncing..."
> sync
> echo " done."
> df -h
>
> I mount an USB stick (currently 128G) on /media/backup (the stick has a
> LUKS encrypted file system on it) and invoke backup.
>
> The only non-quite obvious thing is the option
>
> --filter="merge $home/.backup/filter"
>
> which controls what (not) to back up. This one has a list of excludes
> (much shortened) like so
>
> - /.cache/
> [...much elided...]
> - /.xsession-errors
> - /tmp
> dir-merge .backup-filter
>
> The last line is interesting: it tells rsync to merge a file .backup-filter
> in each directory it visits -- so I can exclude huge subdirs I don't need
> to keep (e.g. because they are easy to re-build, etc.).
>
> One example of that: I've a subdirectory virt, where I keep virtual images
> and install media. Then virt/.backup-filter looks like this:
>
> + /.backup-filter
> + /notes
> - /*
>
> i.e. "just keep .backup-filter and notes, ignore the rest".
>
> This scheme has served me well over the last ten years. It does have its
> limitations: it's sub-optimal with huge files, it won't probably scale
> well for huge amounts of data.
>
> But it's easy to use and easy to understand.
>
> Cheers
> -- t
Reply to: