i am trying to copy files from a SCO Openserver 5.0.6 to a NAS Server using NFS. I have a cron job that takes 1.5 hours to run and most of the data is static. I would like to find a faster way. In the event I needed to running manually or avoid an issue with taking down the servers due to thunderstorms. Below is a copy of the shell script.
Any help will be much appreciated.
# ********************************************************************
# *
# * Script Name : sysbck
# *
# * Description : Performs system backup to a remote NSF share
# *
# *********************************************************************
# * Copyright 2015-20xx by Trolley Computers
# *********************************************************************
#!/bin/sh
# *********************************************************************
# * V A R I A B L E S
# *********************************************************************
# *********************************************************************
# * F U N C T I O N S
# *********************************************************************
# *********************************************************************
# * E R R O R H A N D L I N G
# *********************************************************************
# *********************************************************************
# * M A I N S C R I P T
# *********************************************************************
echo ==============================
date
echo ==============================
#
# Mount Remote NSF Share
#
echo ""
echo "Mount Remote NSF Share"
echo ""
/etc/mount /mnt/pmsroot
sleep 3
echo ""
echo ""
df -v
#
# Remove Specific Directories
#
echo ""
echo "Remove Specific Directories"
echo ""
cd /mnt/pmsroot
rm -fr /mnt/pmsroot/bin
rm -fr /mnt/pmsroot/ecs
rm -fr /mnt/pmsroot/angrist
rm -fr /mnt/pmsroot/fercho
rm -fr /mnt/pmsroot/huppert
rm -fr /mnt/pmsroot/nena
rm -fr /mnt/pmsroot/sc60
rm -fr /mnt/pmsroot/trolley
echo ""
lc
#
# Backup Files
#
echo ""
echo "Backup Files..."
echo ""
cp -Rp /u2/* /mnt/pmsroot/.
echo ""
lc
#
# Un-Mount Remote NSF Share
#
cd
echo ""
echo "Un-Mount Remote NSF Share"
echo ""
/etc/umount /mnt/pmsroot
echo ==============================
date
echo ==============================
# *********************************************************************
# * E X I T S C R I P T
# *********************************************************************
Well the only way to speed up the process is not to copy entire hierarchy every time a script is ran.
Have you considered using rsync , since the data is static it will only copy changes every time it is ran ?
Using rsync the script will probably be couple of lines long.
How big is the directory (size and number of files) and how much bandwidth do you have ?
Perhaps you could also speed up the process with various mount options for NFS or setting atime off for the source mountpoint, but one can only guess.
Other approach is to have a checksum table of all files (source and destination) in perhaps sqlite3 database or a plain text file which you will ran you script against so it only copies the changes.
This will require a bit more effort tho unlike couple of rsync lines
Also, the script posted in post #1 appears to be using a single NAS backup volume (defined in /etc/fstab). IMO an approach like this should only be used if there are multiple backup NAS volumes, either taken from the host itself or from the NAS volume.
Otherwise this would not be a secure way of doing it, since it first wipes the old backup before making a new one, so if anything happens during that backup you end up with nothing..
I did not find rsync on the Skunkware website for OSR5. I did download, compile and install version 3.1.2 from the website for Rsync. I am going to need to learn how to use it.
I did notice on my NAS device, there is a service called rsync.
Yes, I need to have a better backup, where I am not messing with previous days backup. I was trying to get something quick and dirty done. I now need to work on something more secure and beneficial to me.
I have finished testing rsync and it works like a charm. As promised, below is the finished shell script.
#!/bin/sh
# *********************************************************************
# *
# * Script Name : sysbck
# *
# * Description : Performs system backup to a remote NSF share
# *
# *********************************************************************
# * Copyright 2015-20xx by Trolley Computers
# *********************************************************************
# *********************************************************************
# * V A R I A B L E S
# *********************************************************************
# *********************************************************************
# * F U N C T I O N S
# *********************************************************************
# *********************************************************************
# * E R R O R H A N D L I N G
# *********************************************************************
# *********************************************************************
# * M A I N S C R I P T
# *********************************************************************
echo ==============================
date
echo ==============================
#
# Mount Remote NSF Share
#
echo ""
echo "Mount Remote NSF Share"
echo ""
/etc/mount /mnt/provmed
sleep 3
df -v
echo ""
echo ""
#
# Backup Files
#
echo ""
echo "Backup Files..."
echo ""
/usr/local/bin/rsync -vruog --delete /u2/* /mnt/provmed/.
echo ""
echo ""
#
# Un-Mount Remote NSF Share
#
cd
echo ""
echo "Un-Mount Remote NSF Share"
echo ""
/etc/umount /mnt/provmed
echo ==============================
date
echo ==============================
# *********************************************************************
# * E X I T S C R I P T
# *********************************************************************
Consider adding -p and -t options to also preserve permissions and time.
Or use rsync -auvH that will also preserve links and other special files (something that cp -rp cannot do).
-a means archive, see