| | |
how to move files and check the completion.
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2009
Posts: 11
Reputation:
Solved Threads: 0
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.
Thanks in Advance.
Prince
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)
deletionandbackup2() { # Remove all old back up greater than retention period find $BACKUPDIR/$1 -type f -mtime +$RETENTION_PERIOD -name "$1-*.ldif" -exec rm -f \{\} \; # Backup ldap $BASEDIR/$1/db2ldif -a $BACKUPDIR/$1/$1-$DATE.ldif -n $2 -n $3 $sleep_backup }
Thanks in Advance.
Prince
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.
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:
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...
bash Syntax (Toggle Plain Text)
#!/bin/bash TARBALL=`date +/root/backup/archive/svn.%Y.%m.%d.tar.bz2` rm -f ${TARBALL} rm -fr /root/backup/data mkdir -p /root/backup/data/trac mkdir -p /root/backup/data/svn trac-admin /var/trac/proj1 hotcopy /root/backup/data/trac/trac-proj1 >> /dev/null 2>&1 trac-admin /var/trac/proj2 hotcopy /root/backup/data/trac/trac-proj2 >> /dev/null 2>&1 svnadmin hotcopy /var/lib/svn/proj1 /root/backup/data/svn/proj1 svnadmin hotcopy /var/lib/svn/proj2 /root/backup/data/svn/proj2 cp -Rp /etc /root/backup/data cp /root/backup/backup.sh /root/backup/data/backup.sh cd /root/backup tar cjf ${TARBALL} data rm -fr /root/backup/data grep Volume3 /proc/mounts >> /dev/null 2>&1 if [ $? -eq "1" ]; then mount -t smbfs -o username=administrator,password=<snipped> //apex2006sql/Volume3 /mnt/Volume3 fi if [ -d /mnt/Volume3/BackupScott/ ] ; then cp ${TARBALL} /mnt/Volume3/BackupScott/ find /mnt/Volume3/BackupScott/ -type f -mtime +7 -iname \*.bz2 -delete fi 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...
![]() |
Similar Threads
- Bat file to move files onto a created subdirectory (Shell Scripting)
- how to move files to another Directory in Python? (Python)
- Script to move files from one location to another (Shell Scripting)
- script to move files that are not in use or open (Shell Scripting)
- BSOD, Misplaced .dll's, and power cycling (Network Security)
Other Threads in the Shell Scripting Forum
- Previous Thread: how to enter for the prompt?
- Next Thread: reading input problem.
| Thread Tools | Search this Thread |






