Backup directories with space in directory name
Karl Auer
kauer at biplane.com.au
Sun Jan 1 02:57:06 UTC 2017
On Sat, 2016-12-31 at 10:14 -0600, Jack McGee wrote:
> Thanks all. It succesfully backed up the My Documents folder, but
> of course, now I want to have it also backup
>
> /usr/local, /var /etc /opt /home
> [...]
> How should I tweak script further to allow that?
The simplest approach is to manually build the tar command:
dir1="/this/is/the/first"
dir2="/this/is/the/second"
dir3="/this/is/the/third"
[...]
tar cfv "$dest/$archive_file" "dir1" "dir2" "dir3"
Alternatively, use bash arrays, here's a link:
http://www.thegeekstuff.com/2010/06/bash-array-tutorial
Array processing in a loop will test your knowledge of quoting :-)
You could also look into tar's -T option.
There are so many backup solutions out there that it is probably a
waste of effort to roll your own for anything complicated (though it's
a great learning experience).
If you do keep going with this project, I suggest you investigate
rsync, in particular the --link-dest and --hard-links options. You
might also look at the old, but still excellent, rdiff-backup utility.
Regards, K.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)
http://www.biplane.com.au/kauer
http://twitter.com/kauer389
GPG fingerprint: A52E F6B9 708B 51C4 85E6 1634 0571 ADF9 3C1C 6A3A
Old fingerprint: E00D 64ED 9C6A 8605 21E0 0ED0 EE64 2BEE CBCB C38B
More information about the ubuntu-users
mailing list