LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Archiving via rsync via shell script (https://www.linuxquestions.org/questions/linux-software-2/archiving-via-rsync-via-shell-script-4175448431/)

waddles 02-03-2013 02:27 AM

Archiving via rsync via shell script
 
I am attempting to contrive a shell script which will allow me to to use rsync and backup only about 6 directories to a DVD or pair of CDs.
1) am I correct in thinking that rsync is designed primarily to collect all directories then exclude until one has the directories of interest or is there a more direct approach?
2) when archiving to a DVD/CD can one put rsync in a for loop and specify the directory to collect files from one at a time and still be writing to the same device (I hope to devise a means of pausing and inserting an n-th CD unless that is known to be difficult)?
This is for Slackware 13.37 desktop.

pan64 02-04-2013 09:14 AM

I think rsync cannot split data and wait for the next CD, but tar can handle devices.

TB0ne 02-04-2013 09:33 AM

Quote:

Originally Posted by waddles (Post 4883453)
I am attempting to contrive a shell script which will allow me to to use rsync and backup only about 6 directories to a DVD or pair of CDs.
1) am I correct in thinking that rsync is designed primarily to collect all directories then exclude until one has the directories of interest or is there a more direct approach?
2) when archiving to a DVD/CD can one put rsync in a for loop and specify the directory to collect files from one at a time and still be writing to the same device (I hope to devise a means of pausing and inserting an n-th CD unless that is known to be difficult)?
This is for Slackware 13.37 desktop.

Never tired to do anything like that with rsync, but have done something similar using scp.

I did the whole copy first to a single directory on my receiving system, then my script would go through and make a sub-directory, and only move 640MB of data from the parent into it; If the next file to be moved would put it over 640MB, then a new subdir would be made, and the file put there. I was left with one directory, which had sub-directories in it, labeled disc1, disc2, etc. Each the size of a CDROM, ready to burn. That may be easier than trying to figure out how much data is rsync is handling on the fly. Just a suggestion.

dilbert_uk 02-04-2013 04:33 PM

rsync is very complex and has a typical manpage very difficult to understand. I spent some time reading the manpage and examples from the Web to exclude directories but there is also an "include" feature.

I use rsync from within my bash_aliases file with an rsync-filter file:

Code:

dilbert@sempron:~$ cat .bash_aliases
[...]
alias rs='rsync -av --exclude-from=$HOME/.rsync-filter /home/dilbert/ /media/FreeAgent_GoFlex_Drive/dilbert/'
dilbert@sempron:~$ cat .rsync-filter
#
# A standard filter file for rsync.
#
# Use it to add include/exclude patterns for the backup script. See sections
# "FILTER RULES" and "INCLUDE/EXCLUDE PATTERN RULES" in rsync's man page for
# more information. Patterns starting with / are anchored like with ^ in
# regular expressions.
#
# Usage: rsync --filter="merge /path/to/this/file".
#

# Universal excludes -- These apply to all subdirs
- [Cc]ache/
 
# Exclude certain directories
 
# Anything in Downloads can be downloaded again, so don't save it
- /.thumbnails/normal/
 
# These are too big to include
 
# These are transient
- /.local/share/Trash/
- /.cache/
 
# Misc files/dirs to exclude
- /.macromedia/
- /.Trash/
- /.xsession-errors*

# EOF
dilbert@sempron:~$



All times are GMT -5. The time now is 10:37 PM.