Hi All,
I have written a script to ensure all my ARCHIVE files are backed up retaining the directory structure.
The Script is--
#!/bin/sh
# Script to take backup of DCS Folders
# The file locations are /ftp/edi_ftp/edi_p/dcsftp/DCS/*/ARCHIVE
DCSITIME=$(perl -e '($ss, $mm, $hh, $DD, $MM, $YY) = localtime(time());printf "%04d%02d%02d%02d%02d", $YY + 1900, $MM + 1, $DD, $hh, $mm')
mkdir /backup/proact/dcs_backup_files/OTHERS/$DCSITIME
for i in `ls -d /ftp/edi_ftp/edi_p/dcsftp/DCS/*/ARCHIVE|cut -f1,2,3,4,5,6,7 -d /`; do cp -pr $i /backup/proact/dcs_backup_files/OTHERS/$DCSITIME/; done
But my requirement is.... I need to take the backup of these files and delete only copied files from original location (Inside ARCHIVE directory there wont be any Sub directories, it will have only files). I cannot delete using normal delete because these files are very dynamic and if I use only `rm ARCHIVE/*`, I have the risk of deleting files which got created between the time of my backup and deletion. I cannot simply move the directory and recreate it because; application may fail at that point of time.
I need help to take the backup with folder structure intact (I'm able to do in the above script) and delete only copied files inside ARCHIVE Folder.
How can I do this??
Regards,
Nagu