Vdubjunkie Posted October 11, 2003 Report Share Posted October 11, 2003 Hello all, First off, let me say that aru would be proud. I've finally bitten the bullet and taken to the (for me) arduous task of learning to script using bash. btw, in searching I did not find my answer, but I did find this: http://www.mandrakeusers.org/viewtopic.php...xclude+multiple ...and, wow is about all I can say. On to my problem. I decided to write up a cool script that I could put a CRON job in for to backup my /home folder minus a few things which take up too much space and are unnecessary. My problem is that the only thing I have found to work is the following: tar --exclude=<first> --exclude=<second> -cjf backupfile.bz2 /home/* In my script I have something like: EXCLD='first second third' and use the $EXCLD in the final line of "code" to execute a tar command. Now, I've tried single quoting, double single quoting, full quoting, separating with semi and full colons and backslashes, everything I can think of to my list of files/directories to exclude so that I can have one --exclude statement, and I just cannot figure out how to make it work. I do believe that I got this idea to work once before by redirecting it to another file using the -X or --exclude-from= and just listing one item per line in that text file, but I'd sort of like to avoid that too if possible. If that is the option, please tell me so I can bite the bullet and move on... :roll: ...oh yeah.. man this is freaking fun. any of you CLI junkies out there putting off scripting should do like me, bite the bullet and learn it. Quote Link to comment Share on other sites More sharing options...
Guest anon Posted October 11, 2003 Report Share Posted October 11, 2003 Can't help you with bash, im not that good at it :( If you can't get a good answer for your problem, you could always run rsync through cron to get the job done. Example: rsync auz --existing Which would archive,update,compress(zip) only the existing files in your backup folder. Not as clever as writing your own script, but it works. Quote Link to comment Share on other sites More sharing options...
aru Posted October 11, 2003 Report Share Posted October 11, 2003 Hello all, First off, let me say that aru would be proud. I've finally bitten the bullet and taken to the (for me) arduous task of learning to script using bash. :lol: yes, I'm proud of you :lol: My problem is that the only thing I have found to work is the following:tar --exclude=<first> --exclude=<second> -cjf backupfile.bz2 /home/* In my script I have something like: EXCLD='first second third' and use the $EXCLD in the final line of "code" to execute a tar command. [...] I do believe that I got this idea to work once before by redirecting it to another file using the -X or --exclude-from= and just listing one item per line in that text file, but I'd sort of like to avoid that too if possible. If that is the option, please tell me so I can bite the bullet and move on... You'll need to use the "--exclude-from" flag, but you don't need to use a file to store the filenames, you can 'emulate' that file, something like: EXCLD='first second third' tar -X <(for i in ${EXCLD}; do echo $i; done) -cjf backupfile.bz2 /home/* The <(stuff) creates a 'virtual file' at /dev/fd/62 containing the output of stuff Quote Link to comment Share on other sites More sharing options...
Vdubjunkie Posted October 18, 2003 Author Report Share Posted October 18, 2003 I knew aru would come through for me. Man I've been having fun. All of a sudden making sense of, and following the process of scripts makes a lot more sense! :P Anyway, I was searching for that post where you showed me how to find a bunch of files meeting criteria, then move it all. After doing that I'm back to bash.edu for some more edumacation Thanks once again man. I only hope one day the code will flow in my head the way it does in yours. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.