Re: Need help with backup shell script
On Nov 21, 2007 2:55 PM, Valerio Daelli [EMAIL PROTECTED] wrote: On Nov 21, 2007 2:39 PM, Andreas Widerøe Andersen [EMAIL PROTECTED] wrote: Hi, I'm working on a shell script that will let me attach (mount) an external USB 2.0 harddrive and to my FreeBSD 6.2 server and perform a full backup of /backup on my server (all files and subfolders) once or twice a week (whenever I run the cronjob). The script must be able to run through a cronjob and the drive must be mounted and unmounted after each job (I will swap between two drives of the same type and size). The script must also remove folders/files older than 30 days. Does anyone use a script like this today that they can share? I'm not a shell scripter myself so any help is highly appreciated. Here's my rough idea/sketch: #! /bin/sh $MOUNT = /external $DATE= date_today mount usb_drive $MOUNT cd /$MOUNT rm all files forlders older than 30 days mkdir /$DATE cp -fr /backup to /$MOUNT/$DATE cd unmount --- #!/bin/sh MOUNT=/external DATE=`date +%Y%m%d%H%M` mount /dev/da2 $MOUNT #Change device name find $MOUNT -mtime +30 -delete mkdir $MOUNT/$DATE cp -rp /backup/* $MOUNT/$DATE umount /external --- Bye Valerio Daelli Hi again and thanks for the replies to my question. I have finally rebuilt world and compiled a new kernel since I didn't have USB support and SCSI/da support in my previous kernel. I have also used your suggestion and created this script that I can run from command line or as a cronjob: #!/bin/sh MOUNT=/external DATE=`date +%Y%m%d%H%M` mount /dev/da0 $MOUNT #Change device name find $MOUNT -mtime +30 -delete mkdir $MOUNT/$DATE rsync -rlpgoD /backup/ $MOUNT/$DATE umount /external dmesg shows: umass0: Generic USB Storage Device, rev 2.00/0.00, addr 2 umass0: Get Max Lun not supported (TIMEOUT) da0 at umass-sim0 bus 0 target 0 lun 0 da0: SAMSUNG HD501LJ 0-10 Fixed Direct Access SCSI-2 device da0: 1.000MB/s transfers da0: 476940MB (976773168 512 byte sectors: 255H 63S/T 60801C) When I try to run my script I get this prompt back: mount: /dev/da0 on /external: incorrect super block (allthough the script seems to continue to run). Am I doing something wrong here or do I need to I need to use one of the other from /dev: ls -la /dev [snip] crw-r- 1 root operator0, 92 Jan 12 03:42 da0 crw-r- 1 root operator0, 93 Jan 12 03:28 da0s1 crw-r- 1 root operator0, 98 Jan 12 03:28 da0s1c crw-r- 1 root operator0, 99 Jan 12 03:28 da0s1d Thanks for any help here! Best regards, Andreas ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Need help with backup shell script
Andreas Widerøe Andersen wrote: #!/bin/sh MOUNT=/external DATE=`date +%Y%m%d%H%M` mount /dev/da0 $MOUNT #Change device name find $MOUNT -mtime +30 -delete mkdir $MOUNT/$DATE rsync -rlpgoD /backup/ $MOUNT/$DATE umount /external When I try to run my script I get this prompt back: mount: /dev/da0 on /external: incorrect super block This fails because you are trying to mount the raw(?) drive and mount is unable to detect what file system it is (by looking at the partition's super block). Am I doing something wrong here or do I need to I need to use one of the other from /dev: You want to use /dev/da0s1d - the main partition on slice 1 on the drive. Sorry, I dont remember the explanation as to why you must use da0s1d instead of da0s1c, but it goes something along the lines of c partition being a shorthand notation for the entire slice, whereas letter d marks the first partition on the slice. Maybe someone here can clarify this? Hope this helps. Jim Bow ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Need help with backup shell script
Hi, I'm working on a shell script that will let me attach (mount) an external USB 2.0 harddrive and to my FreeBSD 6.2 server and perform a full backup of /backup on my server (all files and subfolders) once or twice a week (whenever I run the cronjob). The script must be able to run through a cronjob and the drive must be mounted and unmounted after each job (I will swap between two drives of the same type and size). The script must also remove folders/files older than 30 days. Does anyone use a script like this today that they can share? I'm not a shell scripter myself so any help is highly appreciated. Here's my rough idea/sketch: #! /bin/sh $MOUNT = /external $DATE= date_today mount usb_drive $MOUNT cd /$MOUNT rm all files forlders older than 30 days mkdir /$DATE cp -fr /backup to /$MOUNT/$DATE cd unmount Thanks for your help! Best regards, Andreas ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Need help with backup shell script
On Nov 21, 2007 2:39 PM, Andreas Widerøe Andersen [EMAIL PROTECTED] wrote: Hi, I'm working on a shell script that will let me attach (mount) an external USB 2.0 harddrive and to my FreeBSD 6.2 server and perform a full backup of /backup on my server (all files and subfolders) once or twice a week (whenever I run the cronjob). The script must be able to run through a cronjob and the drive must be mounted and unmounted after each job (I will swap between two drives of the same type and size). The script must also remove folders/files older than 30 days. Does anyone use a script like this today that they can share? I'm not a shell scripter myself so any help is highly appreciated. Here's my rough idea/sketch: #! /bin/sh $MOUNT = /external $DATE= date_today mount usb_drive $MOUNT cd /$MOUNT rm all files forlders older than 30 days mkdir /$DATE cp -fr /backup to /$MOUNT/$DATE cd unmount --- #!/bin/sh MOUNT=/external DATE=`date +%Y%m%d%H%M` mount /dev/da2 $MOUNT #Change device name find $MOUNT -mtime +30 -delete mkdir $MOUNT/$DATE cp -rp /backup/* $MOUNT/$DATE umount /external --- Bye Valerio Daelli ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Need help with backup shell script
=?ISO-8859-1?Q?Andreas_Wider=F8e_Andersen?= writes: Does anyone use a script like this today that they can share? I'm not a shell scripter myself so any help is highly appreciated. My current scripts are appended; constructive criticism is welcome. And the key to = 30 days would involve find. Robert Huff full_backup #!/bin/sh #set -x # # Set variables # PATH=/bin:/sbin:/usr/sbin:/bin:/usr/bin echo Backup started. at `date` DUMP_DATE=`date | awk '{printf %d.%s.%d\n, $6, $2, $3}'` DUMP_DAY=`date | awk '{print $1}'` DUMP_LEVEL=0 DUMP_CACHE=32 DUMP_DEVICE=/backup DUMPDATES_FILE=/etc/dumpdates export DUMP_DATE DUMP_DAY DUMP_LEVEL DUMP_CACHE DUMPDATES_FILE #make the drive available #mount /dev/da3a /backup mount $DUMP_DEVICE if [ $? -eq 0 ]; then echo /backup clean else fsck -y $DUMP_DEVICE fsck $DUMP_DEVICE echo /backup cleaned mount $DUMP_DEVICE fi echo Disk mounted cd $DUMP_DEVICE/$DUMP_DAY echo Using `pwd` chflags -R noschg . /etc/backup/dump_root /etc/backup/dump_var /etc/backup/dump_usr # show disk usage du -k $DUMP_DEVICE/$DUMP_DAY # Clean up and go home cd /tmp sleep 5 umount $DUMP_DEVICE echo Disk unmounted. echo Backup complete. at `date` dump_usr #! /bin/sh #set -x # Set variables PATH=/bin:/sbin:/usr/sbin:/bin:/usr/bin # # backup /usr # if [ ! -d usr ]; then mkdir usr fi cd usr if [ $? -eq 0 ]; then pwd LINES=`ls -al /backup/$DUMP_DAY/usr | wc -l` if [ $LINES -ne 3 ]; then rm -r * fi echo Usr dump $DUMP_LEVEL -D $DUMPDATES_FILE -C $DUMP_CACHE -Lau -f $DUMP_DATE.usr.dump /usr if [ $? -eq 0 ]; then # #Compressing the weekly isn't worth the effort # (takes too long relative to space reclaimed) # if [ $DUMP_LEVEL -ne 0 ]; then echo Compressing with gzip... gzip $DUMP_DATE.usr.dump # echo Compressing ... # tar -czf $DUMP_DATE.usr.dump.tgz $DUMP_DATE.usr.dump \ # rm $DUMP_DATE.usr.dump echo done fi else echo Dump suceeded. fi cd .. fi ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Need help with backup shell script
--- #!/bin/sh MOUNT=/external DATE=`date +%Y%m%d%H%M` mount /dev/da2 $MOUNT #Change device name find $MOUNT -mtime +30 -delete mkdir $MOUNT/$DATE cp -rp /backup/* $MOUNT/$DATE umount /external --- Please substitute the line starting with 'cp' with this one: rsync -rlpgoD /backup/ $MOUNT/$DATE (you must portinstall rsync as well) since 'cp -rp' preserve modification times as well while 'rsync -rlpgoD' preserve permission but not mtime. Sorry Valerio Daelli ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Need help with backup shell script
Robert Huff [EMAIL PROTECTED] writes: And the key to = 30 days would involve find. I like to put the date in the names of the backup files. That way the date is a little less fragile... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]