944,198 Members | Top Members by Rank

Ad:
Nov 5th, 2009
0

how to move files and check the completion.

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
john_prince is offline Offline
20 posts
since Jan 2009
Nov 5th, 2009
0
Re: how to move files and check the completion.
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; Nov 5th, 2009 at 2:11 pm.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Nov 5th, 2009
0
Re: how to move files and check the completion.
Yes, we need to do this using shell script.

Thank you.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
john_prince is offline Offline
20 posts
since Jan 2009
Nov 5th, 2009
0
Re: how to move files and check the completion.
Here is my backup script for trac/svn. Entirely unrelated to this thread but maybe there are code examples you would benefit from:
bash Syntax (Toggle Plain Text)
  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...
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: how to enter for the prompt?
Next Thread in Shell Scripting Forum Timeline: reading input problem.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC