1. Please use CODE tags instead of QUOTE tags for command lines. It makes it easier to read.
2. No, I'm afraid your command line will remove old sub-directories in the file trees, that you want to keep. Instead, I suggest that you remove the old backup [file tree] manually, to have full control until you develop and test another command line. List the directory, where you store the backups, and removed the oldest one when your sure there is a newer version.
3. I think the following command line is safer to list the directories (but not subdirectories below that level)
Code:
for i in *;do if test -d "$i";then echo "$i";fi;done
4. I use rsync, which is a very good tool. It works incrementally as coldraven wrote. When you want a fresh start (and get rid of files files in the backup, that you deleted from the source and you no longer want), just back up to a new directory. I often use
Code:
sudo rsync -Havn /path-to-source/ /path-to-target # dry run
sudo rsync -Hav /path-to-source/ /path-to-target # real copying
Notice the slash after 'path-to-source'. It is important. See
Code:
A trailing slash on the source changes this behavior to avoid creating an addi‐
tional directory level at the destination. You can think of a trailing / on a
source as meaning "copy the contents of this directory" as opposed to "copy the
directory by name", but in both cases the attributes of the containing directory
are transferred to the containing directory on the destination. In other words,
each of the following commands copies the files in the same way, including their
setting of the attributes of /dest/foo:
rsync -av /src/foo /dest
rsync -av /src/foo/ /dest/foo
You can 'dry run' rsync backwards and get a list of files in the backup, that you have deleted in the source.
Code:
sudo rsync -Havn /path-to-target/ /path-to-source
It is very important to get everything correct. So test with small directory trees, make shellscript files, edit them until you are happy, and then start using them to backup your home directory.
Bookmarks