Code: Select all
#!/bin/bash
for i in `cat viking.backup`;
do rsync -azrvv --delete --delete-excluded --exclude-from 'ex.txt' $i /media/My?Book/thomas-pc_backup/;
doneIf you wonder about the ? in My?Book it is necessary because omitting will not work in rsync for HD names with spaces.
The files viking.backup and ex.txt must be in the same directory as the script. Preferably at /home/<your_name>/
In viking.backup is where I put what I want to backup:
Code: Select all
/home/thomas
/etcAs you can see I want to backup the entire <your_name> directory
I also want a complete backup of the etc directory
Since I want that, I have to run the backup as root.
Now that will present an error because the file /home/<your_name>/.gvfs is spesifically denied too root so we have to exclude it from the backup if we want to run it as root. So it will get an honorable mentioning in my ex.txt file where I keep all the files and directories that should be excluded:
Code: Select all
*/tmp #excludes the entire tmp directory
*/.config/gsmartcontrol/* #excludes the content of your /home/<your_name>/.config/gsmartcontrol directory
*/.cache/* #based on the above; what do you think this does :)
*/.gvfs
I use the * instead of <your_name> which is more elegant.
This works! The excluding works. BUT the deletion of excluded, already existing files, on the backup does not happen.
Depending om my mood I will now try to sort out the delete problem or refine functionality of the script a bit further....
Edit: I solved the delete problem and edited the code above
Now the functionality is perfect. Going on to play with the script now....



