#!/usr/bin/ksh #---------#---------#---------#---------#---------#---------#---------#--------- # # Date: 06 sep 2000 # Title: backup ldap db to another machine using tar and ftp # Creator: idc # Description: # check disk space, remove the previous backup # backup the Netscape Directory database # copy to another machine using ftp # eg. one slave server to another # Modifications: # #---------#---------#---------#---------#---------#---------#---------#--------- # setup # # locations and names # server_dir=/data/netscape/ds-slave/slapd-ds01 bak_dir=${server_dir}/bak cd $bak_dir latest_backup=$(ls -t | head -1) echo "backup directory: ${bak_dir}/$latest_backup " tar_backed=/tmp/slave2_BACKUP_${latest_backup}.tar compressed_backed=/tmp/slave2_BACKUP_${latest_backup}.tar.Z cksum_file=${compressed_backed}.cksum # main # remove the old archive # if [[ -f $tar_backed ]]; then rm $tar_backed echo "removed the previous backup archive: $tar_backed" fi if [[ -f $compressed_backed ]]; then rm $compressed_backed echo "removed the compressed backup archive: $compressed_backed" fi if [[ -f $cksum_file ]]; then rm $cksum_file echo "removed the checksum file: $cksum_file" fi # # create a new archive # echo "creating the archive: $compressed_backed " cd /tmp # check archive dir disk space tar_disk_info=$(df -k .) tar_space_avail=$(echo $tar_disk_info | cut -d' ' -f11) echo "disk space available for the archive : $tar_space_avail k " cd $bak_dir tar -cvf $tar_backed $latest_backup compress $tar_backed cd /tmp tar_used_in_bytes=$(ls -l $compressed_backed | tr -s ' ' ' ' | cut -f5 -d' ') tar_used=$(expr $tar_used_in_bytes / 1024 ) echo "disk space used by the archive: $tar_used k " # # copy the archive and checksum to the target machine # cd /tmp cksum $compressed_backed > ${compressed_backed}.cksum ftp -n <