Automated backup script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Automated backup script
# 1  
Old 06-18-2009
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
# 2  
Old 06-18-2009
i am not clear what your requirement is?
can you pls post the exact need?
# 3  
Old 06-19-2009
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.
# 4  
Old 06-20-2009
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).
# 5  
Old 06-20-2009
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.
# 6  
Old 06-26-2009
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?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need an automated script

Hi, I need a script to execute below task. As of now I am doing it manually and want it automated. 1)go to below path cd /path/of/file check for the availibility of two file as below of the latest date. test.week1.data test.week2.data Case1. If above files are not present... (3 Replies)
Discussion started by: sv0081493
3 Replies

2. Shell Programming and Scripting

Help with Backup Shell Script for Network Device Configuration backup

HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here Im explaining the requirement of script. AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Discussion started by: saichand1985
4 Replies

3. UNIX for Dummies Questions & Answers

how to make script automated

if i have a script called test.sh file1=$(ls -l|awk '{print $9 $1}') awk ' /date_of_selling:/ { print $6 ":" &9 }' /$file1 >> data.txt if i wanna this script to run automatically every day at 8 am :D (3 Replies)
Discussion started by: teefa
3 Replies

4. Shell Programming and Scripting

Help with Automated Shell Script

Hello, how can I write a shell script that looks in running processes and if there isn't a process name containing 91.34.124.35 then execute a file in a certain place. I know PHP, in PHP I could do a preg_match_all but I don't know how to do it in shell. (5 Replies)
Discussion started by: nottingham
5 Replies

5. Shell Programming and Scripting

Syntax error with automated backup script

Hi guys, I'm new to Linux and dont know much of scripting..there's an automated backup script that will backup the database from a location to another location between servers..it was created by another person and I tried to understand it somewhat.. I hope the script first checks if mount... (4 Replies)
Discussion started by: koolhart
4 Replies

6. UNIX for Advanced & Expert Users

scp automated script

Hi Unix gurus, I am trying to create a script to automate the copying of files daily from one server to another using the scp command. --> #!/bin/ksh KEY="$HOME/.ssh/SSHKEY" if ;then echo "Private key not found at $KEY" >> $LOGFILE echo "* Please create it with \"ssh-keygen -t dsa\" *"... (5 Replies)
Discussion started by: gholdbhurg
5 Replies

7. Shell Programming and Scripting

Automated SFTP script

Hi All, I am writing an automated SFTP script to xfer files. I am able to do sftp in batch mode and it is working absolutely fine. The problem is that on redirecting the output of SFTP session to some file, it is not writing about the status of SFTP operation. All i can see in output file is :... (6 Replies)
Discussion started by: aggar_y
6 Replies

8. Shell Programming and Scripting

i want automated script

echo "Enter your choice :\c" read num case $num in . 1)"${TEST_HOME}"/ctrl_extract.ksh 1 ;; 2)"${TEST_HOME}"/ctrl_extract.ksh 2 ;;3)"${TEST_HOME}"/ctrl_extract.ksh 3 ;; 4)"${TEST_HOME}"/ctrl_extract.ksh 4 ;; 5)"${TEST_HOME}"/ctrl_extract.ksh 5 ;;... (3 Replies)
Discussion started by: arghya_owen
3 Replies

9. Shell Programming and Scripting

automated sftp script

Ok, I am sure this has been beat like a dead horse, but I an trying "anew". I am trying to create a script that will automate a file transfer using sftp. Please, I am at rock bottom. Thank you. (2 Replies)
Discussion started by: klindel
2 Replies

10. UNIX for Advanced & Expert Users

help for automated script

Hi ALL: I need to write a script that will start bunch of servers. and these servers each has a sudo account and they need a passowrd. I dont know where to start and look. Can you please give me some hints or some sample code. Thanks in advance. splax (4 Replies)
Discussion started by: splax
4 Replies
Login or Register to Ask a Question