vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| pgp trash troll delete Alan Hicks 188 Shady Dale Dr Lizella, GA 31052 478-935-8132 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Heads up. Quit spamming. That's all this is, plain and simple. If you wanted to know if some one out there could help _you_ do your script, that would be different, but should still be asked in a more on-topic newsgroup like comp.unix.shell. In alt.os.linux.slackware, Jeromy D. Alexander dared to utter, > Need a simple script that will run from a crontab (once per hour?) to do: > > 1. test for cdr media in the cdrw drive, if found - continue, if not exit. > (on exit, no error msg.. just wait for next cron run and try again) I think cdrecord has a --test option or something that you can run and check its exit code to do this. > 2. build an iso image from a directory (~100mb) and as many .zip files > as possible. > the zips are nightly snapshots of the directory. stored with the > date in the filename, the script would have to add as many of the most > recent .zips as would fit on the media. each file is about 65mb.. so it > would should have room for the directory and 7 or 8 files.. of course > the files sizes will increase over time, so it needs to be checking the > total file size as it adds them (700mb max total) This is tougher, as mkisofs will not allow you to include/exclude individual files, only directories. Most likely you'll have to create a sub-directory here and move the 6 or 7 most recent zips to that location, then tell mkisofs to make the iso of that directory. Of course you can do some trivial awk to calculate the size of the files and if greater than say 650MB, dump the oldest one and try again. Probably need at least one while loop for that. > 3. burn & test the image and eject the disk. No big deal there. > 4. send an email - details of task completed (current dir xxx MB, + 3 > zips xxx MB each) or possibly (current dir 500 MB, no room for addition > zips) > etc... This is something I've been wanting to do and just haven't gotten around to doing just yet. > This script will allow the (non-technical) office staff to make 'hard > copy' backups as often as they wish.. just walk over to the server box > (no keyboard/monitor/mouse), hit the button to open the cd tray, put in > a blank disk, and then just wait to get an email saying its done, go > back and pick up the disk, and close the tray. I use the following script for almost the same thing and should do basically what you need. There's no testing for a cd in the drive, it just assumes one is always there and errors out if not available (I use this five nights a week, not hourly). At the moment, there's no e-mail notification, though I've been wanting to add something like that for some time now. ================================================== ==================== #!/bin/bash # Copyright 2005 CTS Macon, Macon, GA, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PATH=/usr/bin:/usr/sbin:/bin:/usr/sbin DATE="$(date +%F)" BACKUP_DIR="/" EXCLUDE_DIRS="/bin /dev /home /lib /mnt /opt /proc /root /sbin /sys /tmp /usr" BACKUP_ISO="/home/backup.iso" CD_DEV="0,0,0" CD_SPEED="8" CD_BLANK_TYPE="all" SAMBA="no" iso_make() { if [ "$SAMBA" = "yes" ]; then /etc/rc.d/rc.samba stop fi if [ ! $? = 0 ]; then echo "Samba refused to stop. Carrying on regardless." echo "Backup may be incomplete or some files may be corrupted." fi mkisofs -o "${BACKUP_ISO}" -R -V "GRWA Backup ${DATE}" \ $(for i in ${EXCLUDE_DIRS}; do echo -n " -x $i "; done) \ ${BACKUP_DIR} &> /dev/null if [ ! $? = 0 ]; then echo "ISO creation failed." exit 10 fi if [ "$SAMBA" = "yes" ]; then /etc/rc.d/rc.samba start fi if [ ! $? = 0 ]; then echo "Samba restart failed for some reason." fi } cd_blank() { cdrecord dev="${CD_DEV}" speed="${CD_SPEED}" blank="${CD_BLANK_TYPE}" if [ ! $? = 0 ]; then echo "CD was not successfully blanked. Backup failed." exit 20 fi } cd_burn() { cdrecord dev="{$CD_DEV}" speed="${CD_SPEED}" "${BACKUP_ISO}" if [ ! $? = 0 ]; then echo "CD was not successfully burned. Backup failed." exit 30 fi } if [ $# -gt 0 ]; then # Parse options while [ 0 ]; do if [ "$1" = "--make-iso" ]; then ISO_MAKE="yes" shift 1 elif [ "$1" = "--image" ]; then if [ $2 ]; then BACKUP_ISO="$2" shift 2 else echo "Must specify an argument to --image." exit 40 fi elif [ "$1" = "--blank" ]; then CD_BLANK="yes" shift 1 elif [ "$1" = "--burn" ]; then CD_BURN="yes" shift 1 else break fi done else # Fall back to defaults ISO_MAKE="yes" CD_BLANK="yes" CD_BURN="yes" fi # Main loop if [ "$ISO_MAKE" = "yes" ]; then iso_make fi if [ "$CD_BLANK" = "yes" ]; then cd_blank fi if [ "$CD_BURN" = "yes" ]; then cd_burn fi ================================================== ==================== BTW, keep your damn $75. That's not worth a real scripter getting out of bed for. - -- It is better to hear the rebuke of the wise, Than for a man to hear the song of fools. Ecclesiastes 7:5 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFCE0w9vgVcFKpJf4gRAi40AKDdijHCWMRank3TnWVAsN CElVR9jACfeK1x alSIA8rFhXCgHjhLr6rWoB4= =UdGj -----END PGP SIGNATURE----- |