how to move files and check the completion.

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2009
Posts: 11
Reputation: john_prince is an unknown quantity at this point 
Solved Threads: 0
john_prince john_prince is offline Offline
Newbie Poster

how to move files and check the completion.

 
0
  #1
27 Days Ago
Hi,

We are taking backups for ldap instances, and with the new requirement would like to keep 1 day's of backup to local disk (/export1) and rest 14 days backup to SAN (/export2). Now we are in kind of fix on how to move the backups ( includes files & folders) to SAN and check if the move has been completed. We use the following subroutine for this. Is there any way we can check the moved backups, i mean in terms of size. Just in order in avoid a kind of situation where we have moved the backup and the size differs.

We would like to update the script to following things:

- Delete backups older than 15 days in /export2.
- Move previous day's backup from /export1 to /export2.
- check move completed successfully on /export2.
- Take backup of /export1.


P.S : This is not the complete script so please ignore variables. Also, i am only need commands and not a different script.

Shell Scripting Syntax (Toggle Plain Text)
  1. deletionandbackup2()
  2. {
  3. # Remove all old back up greater than retention period
  4. find $BACKUPDIR/$1 -type f -mtime +$RETENTION_PERIOD -name "$1-*.ldif" -exec rm -f \{\} \;
  5. # Backup ldap
  6. $BASEDIR/$1/db2ldif -a $BACKUPDIR/$1/$1-$DATE.ldif -n $2 -n $3
  7. $sleep_backup
  8. }

Thanks in Advance.

Prince
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,224
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 574
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast
 
0
  #2
27 Days Ago
Have you considered using rsync for this task? If you really want to do this with a shell script then let me know and i'll try to dig up an example.
Last edited by sknake; 27 Days Ago at 2:11 pm.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 11
Reputation: john_prince is an unknown quantity at this point 
Solved Threads: 0
john_prince john_prince is offline Offline
Newbie Poster
 
0
  #3
27 Days Ago
Yes, we need to do this using shell script.

Thank you.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,224
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 574
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast
 
0
  #4
27 Days Ago
Here is my backup script for trac/svn. Entirely unrelated to this thread but maybe there are code examples you would benefit from:
  1. #!/bin/bash
  2. TARBALL=`date +/root/backup/archive/svn.%Y.%m.%d.tar.bz2`
  3. rm -f ${TARBALL}
  4. rm -fr /root/backup/data
  5.  
  6. mkdir -p /root/backup/data/trac
  7. mkdir -p /root/backup/data/svn
  8.  
  9. trac-admin /var/trac/proj1 hotcopy /root/backup/data/trac/trac-proj1 >> /dev/null 2>&1
  10. trac-admin /var/trac/proj2 hotcopy /root/backup/data/trac/trac-proj2 >> /dev/null 2>&1
  11.  
  12. svnadmin hotcopy /var/lib/svn/proj1 /root/backup/data/svn/proj1
  13. svnadmin hotcopy /var/lib/svn/proj2 /root/backup/data/svn/proj2
  14.  
  15.  
  16. cp -Rp /etc /root/backup/data
  17. cp /root/backup/backup.sh /root/backup/data/backup.sh
  18.  
  19. cd /root/backup
  20. tar cjf ${TARBALL} data
  21. rm -fr /root/backup/data
  22.  
  23. grep Volume3 /proc/mounts >> /dev/null 2>&1
  24.  
  25. if [ $? -eq "1" ]; then
  26. mount -t smbfs -o username=administrator,password=<snipped> //apex2006sql/Volume3 /mnt/Volume3
  27. fi
  28.  
  29. if [ -d /mnt/Volume3/BackupScott/ ] ; then
  30. cp ${TARBALL} /mnt/Volume3/BackupScott/
  31. find /mnt/Volume3/BackupScott/ -type f -mtime +7 -iname \*.bz2 -delete
  32. fi
  33.  
  34. find /root/backup/archive/ -type f -mtime +30 -iname \*.bz2 -delete

As for what you want to do -- what doesn't your script do that you want it to? From your example (if it works) you know how to copy the data and delete old files...
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC