Help needed to backup files.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help needed to backup files.
# 1  
Old 04-09-2010
Help needed to backup files.

Hi guys ,

I m writing a script which will backup a particular folder and its content to a different location.

this script needs to be run every weekend.

But my problem is how would i apply logic such that the previous backup folder is only deleted if and only if the current backup is successful.
code written by me.
PHP Code:
cp /OVS/running_pool/$VM_Guest/*.* /mnt/ntserver/$VM_Guest/

if [ "$?" -ne "0" ]; then
  echo "Problem in copying the data"
fi 

Last edited by pinga123; 04-09-2010 at 08:20 AM..
# 2  
Old 04-09-2010
First take a copy of existing backup in a temp folder.
If it is successfull then do the backup. If the backup fails then restore the old back up from the temp directory.

Here is a sample . You can modify it as per your requirement.
Code:
mkdir /mnt/ntserver/$VM_Guest/temp

cp /mnt/ntserver/$VM_Guest/*.* /mnt/ntserver/$VM_Guest/temp/

if [ "$?" -ne "0" ]; then 
  echo "The old back up copied procced with new" 
else
exit
fi  

cp /OVS/running_pool/$VM_Guest/*.* /mnt/ntserver/$VM_Guest/

if [ "$?" -ne "0" ]; then 
  echo "Problem in copying the data resore the old"

 cp /mnt/ntserver/$VM_Guest/temp/*.* /mnt/ntserver/$VM_Guest/
else 
echo " Back up Done without issue
fi

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help Needed for creating the folder by checking today's date and, take backup using rsync command

How to create a shell script to create a folder by using the today's date to take backup using rsync command on every evening around 7 pm. Kindly help. Thanks. To be more precise, I want to create a script which matches the today's date with server's date format, if matches then creates the... (2 Replies)
Discussion started by: bakula10
2 Replies

2. AIX

How to backup a directory (sub-directories/files) files from one server on to other ?

Hello, Server A: /directory1/ Server B: /Backups/ i wanted to backup contents of /directory1 from "server A" on to "Server B" every 1 hour. If there is any change in (only new/differences) contents on serverA (directory1/) supposed to be backeup on next run. I did used rsync command to... (5 Replies)
Discussion started by: System Admin 77
5 Replies

3. Shell Programming and Scripting

Backup of index.* files

Sir, My server is hacked. Server administrator is saying that hacker used 0day CentOS kernal exploit to hack it. Now administrator updated the kernal and rebooted the server. But he is unable to cath the hacker, or how he initiated the process. So therefore i need your help in following... (5 Replies)
Discussion started by: SimonFrance
5 Replies

4. Shell Programming and Scripting

Backup Files

Hi, Using the shell script, how can I backup the files. /etc/password, /etc/group , /etc/shadow and more and needs a backup like /etc/password.12Mar12.... (4 Replies)
Discussion started by: gsiva
4 Replies

5. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

6. Shell Programming and Scripting

Help needed with backup shell script

Hi, I'm develpoing a shell script which takes backup for an Oracle database. Requirement is, the script should exit when it find another instance of the same script being run on the server. I'm not able to perform the check using the shell script name using ps command. when i use ps command... (3 Replies)
Discussion started by: senthil3d
3 Replies

7. Shell Programming and Scripting

Backup files

Greetings. I've got a little bit of problem with writing a script. I'd like to write a script that creates backup files (of your computer) once a week, and on the other days of the week it just updates it. Thanks in advance i hope you can help: buddhist p.s.: this would help a lot, because... (1 Reply)
Discussion started by: buddhist
1 Replies

8. Shell Programming and Scripting

SUM of Backup Files

Hello Everyone, I'm struggiling with backup issues and need to sum up sizes of backup files monthly and add the result to the next month's sum recursively. For this i have a well working script that i modified as i showed below and this part gives the sum of the file sizes under working... (2 Replies)
Discussion started by: EAGL€
2 Replies

9. HP-UX

Backup Script using fbackup command Help Needed.

Hi Friends, I'm new to unix, I have the below script which takes regular backup. Now if fbackup fails I get the below messages in my log as fbackup(3047): could not open output file /dev/rmt/0m fbackup(3019): would you like to enter a new output file? fbackup(3004): writer aborting... (4 Replies)
Discussion started by: avik.nandi
4 Replies

10. UNIX for Dummies Questions & Answers

Backup my files to DAT

hi guys, im using tru64 unix and i want to put my files on tapes. i have already a hp DAT storage, do you have any admin guides for backup/restore procedures for these? tnx (1 Reply)
Discussion started by: jefferson
1 Replies
Login or Register to Ask a Question