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.

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

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.

Edited 7 Years Ago by sknake: n/a

Here is my backup script for trac/svn. Entirely unrelated to this thread but maybe there are code examples you would benefit from:

#!/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...

This article has been dead for over six months. Start a new discussion instead.