![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sftp automated script | javeed7 | Shell Programming and Scripting | 3 | 01-08-2009 03:41 PM |
| scp automated script | gholdbhurg | UNIX for Advanced & Expert Users | 5 | 10-27-2008 01:23 AM |
| i want automated script | arghya_owen | Shell Programming and Scripting | 3 | 06-16-2008 09:02 AM |
| Need automated shell script please | uneex | Shell Programming and Scripting | 2 | 05-02-2008 08:36 AM |
| help for automated script | splax | UNIX for Advanced & Expert Users | 4 | 12-26-2006 05:36 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Automated backup script
I want to create an automated backup script that will copy files to different directories for different days. I will use a detachable USB drive, under SCO 5.0.7. I am very new to Unix, and will require most of the script. Thanks
|
|
||||
|
Hi amitranjansahu, I want to use two external USB hard drives to do my daily backups to, instead od a tape streamer. On the two hard drives I want to create a directory for each day of the week and back the data up to the relevant directory, ie. on Tuesday it will back up to /dev/d45050 /TUESDAY etc. This backup runs automatically in the evening. Instead of using the tar command, I will just copy the files to /dev/d45050. However, I want the system to automatically select the relevant directory to copy to on /dev/d45050 every day.
|
|
||||
|
Do you know any scripting at all? Start looking at man pages and testing individual commands at the command line. Then put them together in a script. The script is basically just a collection of command line commands (though it can get more complicated and include conditional statements and such).
Start with `man date`. With the right options, you can get the date command to spit out the day of the week. It's kind of dangerous to just take scripts from other people when you don't understand any of the details yourself (and, if it happens to be homework, it doesn't help you learn very well). |
|
||||
|
This is based on similar stuff on 5.0.5 used earlier:
In crontabs modify root to add 7 tasks, each at the same time on different days pointing to the different files: 15 03 * * 0 /usr/bin/sunday 15 03 * * 1 /usr/bin/monday etc in /usr/bin create 7 files by day name for example sunday rm /usb/sunday/*.* sleep 60 cp /dir/*.* /usb/sunday You have to change this to your directories and filesystem requirements. You have to make provisions for creating and attaching the USB drive and for properly swapping it out each week. I've never used a USB so it sounds reasonable except for the possibility that they can glitch and you lose all protection. With 5.0.5 I used a cd-rw to do the storage, one every night at a cost of less than $50 per year, and I also used a backup program to compress and create a single file for burning. Backup to an internal drive at 03:15, create ISO image at 04:15, burn at 05:15, and move the backup file into a day of week file at 06:15. |
|
||||
|
I created the following script that works. This is only the first part of the script to save space.
# This script backs up data by copying data to a directory on an # external usb hard drive, corresponding to that day of the week date '+ %w' > DTE WDY=`grep . DTE` MD=1 TU=2 WD=3 TD=5 FD=5 ST=6 SU=0 if [ $WDY -eq $MD ] then mount /dev/d45050 /EXTBCK cd /usr/ims1 ls /EXTBCK/MONDAY > FLETST if test -e /EXTBCK/MONDAY then rm -r /EXTBCK/MONDAY/* fi cp -r /dir/subdir/*.* /EXTBCK/MONDAY umount /dev/d45050 exit else exit fi As a substitute for the weekdays, I want to create a directory on the backup device equal to the current date, ie 24Jun09, using the following script. DAY= date '+%d%b%y' mkdir /EXTBCK/$DAY My intention is to then copy the data to these directories instead of weekdays However, it does not create a directory, but gives an error, file already exists error 17 Can it be done? ---------- Post updated at 01:57 PM ---------- Previous update was at 12:16 PM ---------- Hi guys. Don't worry I came right with the following script: mount /dev/d45050 /ARCHIVE mkdir /ARCHIVE/`date +%d%b%y` cp /dir/subdir/* /ARCHIVE/`date +%d%b%y` umount /dev/d45050 ---------- Post updated 26th Jun 2009 at 11:15 AM ---------- Previous update was 25th Jun 2009 at 01:57 PM ---------- I am creating an archive on a usb hard drive by copying the files with the cp command into a directory equal to the current date. I want to build in a switch that will overwrite the oldest directory as soon as the disk runs out of space. Can that be done automatically? ---------- Post updated at 11:16 AM ---------- Previous update was at 11:15 AM ---------- I am creating an archive on a usb hard drive by copying the files with the cp command into a directory equal to the current date. I want to build in a switch that will overwrite the oldest directory as soon as the disk runs out of space. Can that be done automatically? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|