baker7 Posted March 6, 2007 Report Share Posted March 6, 2007 I have a quick question:I have a linux host where I want to archive files with TAR - what I want to do is:1. Take ALL files in /home/bsbaker (including the dotfiles) and tar them up and give the file a name like KUS-home-xx-xx-xx.tar (with xx-xx-xx being the date of the backup file)2. Take ALL files in /home/bsbaker/public_html/ (including the dotfiles) tar them up and give the file a name like KUS-web-xx-xx-xx.tar (with xx-xx-xx being the date of the backup file)3. Take ALL files in /home/bsbaker/public_html/secure/ (including the dotfiles) tar them up and give the file a name like KUS-secure-xx-xx-xx.tar (with xx-xx-xx being the date of the backup file)4. Take ALL files in /home/bsbaker/public_html/secure/dke/ (including the dotfiles) tar them up and give the file a name like DKE-web-xx-xx-xx.tar (with xx-xx-xx being the date of the backup file)5. When competed, have a message mailed to my email on the machine - telling me that the job is done. I want to do this MONTHLY - then download the tar files to my machine by going in and using SFTP to do this.Is there a script that I can make that will allow the process to commence? NOTE: I am NOT root on this machine - just a user - this script should allow me to do a backup with just a script run.Any idas Team??Brian Quote Link to post Share on other sites
shanenin Posted March 7, 2007 Report Share Posted March 7, 2007 a bash script would work great for this. Linux really makes automating stuff relatively easy. Do you know how to do this manually, if so, just put the commands that you normally use into a list(or script). I could help you script it, if you could show me for example what tar command you are using. Quote Link to post Share on other sites
jcl Posted March 7, 2007 Report Share Posted March 7, 2007 (edited) Questions: When you say "all files", does that include the files that will be in the other tarballs? Frex, does the backup of /home/bsbaker include /home/bsbaker/public_html? Do you really need four tarballs? Could you tar up the whole $HOME and break it apart later if needed? What's the root directory of the tarballs? Frex, should DKE-web expand to /home/bsbaker/public_html/secure/dke/, or public_html/secure/dke/, or dke/, or what? Does your host provide a less stupid way to backup user accounts? rsync or something? Edited March 7, 2007 by jcl Quote Link to post Share on other sites
baker7 Posted March 7, 2007 Author Report Share Posted March 7, 2007 (edited) Questions: When you say "all files", does that include the files that will be in the other tarballs? Frex, does the backup of /home/bsbaker include /home/bsbaker/public_html? Do you really need four tarballs? Could you tar up the whole $HOME and break it apart later if needed? What's the root directory of the tarballs? Frex, should DKE-web expand to /home/bsbaker/public_html/secure/dke/, or public_html/secure/dke/, or dke/, or what? Does your host provide a less stupid way to backup user accounts? rsync or something?This is what I wanted.I have a home directory tar file that with everything I have its 64 MEG. I have a web directory public_html that is about 40 MEG and a secure directory that is about 5 megs. I work for D&K Enterpises, and the secure/dke directory is his website that I am running as a test on my linux host. I have to back this up as well.Rather then to take the whole 64 megs every time, I want to break it down so that /home/bsbaker is ONE file, /home/bsbaker/public_html/ is ANOTHER file, and /home/bsbaker/public_html/secure is a third file. if necessary I will add /home/bsbaker/public_html/secure/dke/ so that I pick up all th files in his website.That way, it does not tun into 100 megs of tar file that I could lose, and iif i wanted to restore just the web files, I could upload that TAR file and viola!!Hope this makes sense Brian Edited March 7, 2007 by baker7 Quote Link to post Share on other sites
baker7 Posted March 7, 2007 Author Report Share Posted March 7, 2007 (edited) a bash script would work great for this. Linux really makes automating stuff relatively easy. Do you know how to do this manually, if so, just put the commands that you normally use into a list(or script). I could help you script it, if you could show me for example what tar command you are using.Cool - a script is exactly what I need - I need to know how to build it though the command I use is as follows (assumes home directory /home/bsbaker/tar -cvf KUS-home-xx-xx-xx.tar * (Tells system to do ALL files, however, I am missing the Dotfiles [xx-xx-xx is date of file]I want to also grab the dotfiles and have this script email me when it is completed then I do the same for the public_html directory and the public_html/secure/dke directory, because I am IN thm whn I tar up the files - aft that, I download all of these I use tcsh as default shell as well, but think I could use bash for this script thanks shanenin :>Brian Edited March 7, 2007 by baker7 Quote Link to post Share on other sites
jcl Posted March 7, 2007 Report Share Posted March 7, 2007 The tar commands would be similar totar -cf KUS-home-${date}.tar --exclude 'public_html' ${dir}tar -cf KUS-web-${date}.tar --exclude 'secure' ${dir}/public_htmltar -cf KUS-secure-${date}.tar --exclude 'dke' ${dir}/public_html/securetar -cf DKE-web-${date}.tar ${dir}/public_html/secure/dkewhere # shdate=$(date +%F)dir=/home/bsbaker# tcshset date=`date +%F`set dir=/home/bsbakerexcept that the --exclude options have to be tweaked. Quote Link to post Share on other sites
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.