Post by alpheratz on Sept 26, 2007 7:05:23 GMT 7
It can be done!
I have FW 1.00.09.
The key is /opt/samba/bin/smbclient (see online manuals [for instance]: www.hmug.org/man/1/smbclient.php):
I am running the following script nightly under cron:
I put this script on the filesystem at /raid/data/LOCAL/bin (and I have also made the directory /raid/data/LOCAL/tmp).
I run this script under cron:
NB: it is necessary to edit the crontab in /app/cfg/crond.conf to ensure persistence across reboots, AS WELL AS to establish this line into the existing system via the command: crontab -e.
Note that this ALSO backs up to the USB disk on /dev/sdc1 (healthy paranoia at work here...)
I backup about 9Gb nightly with this.
There are actually a LOT of example scripts to do this sort of thing with smbclient on the 'net'...this is just mine, FYI.
Cheers,
Alph
I have FW 1.00.09.
The key is /opt/samba/bin/smbclient (see online manuals [for instance]: www.hmug.org/man/1/smbclient.php):
/opt/samba/bin/smbclient -U ${UNAME}%${PASSWD} ${SHARE} \
-c "put ${BACKUP} ${BACKUP_FILE}" 2>&1 > /dev/null
I am running the following script nightly under cron:
#!/bin/sh
# usage: backup.sh source share device
APPNAME=`basename $0 .sh`
LOG=/tmp/${APPNAME}.log
echo "${APPNAME}: running at `date`..." > ${LOG}
SOURCE=$1
SHARE=$2
DEVICE=$3
TMPDIR=/raid/data/LOCAL/tmp
BACKUP_FILE=`hostname -s`.${APPNAME}.`date +%Y-%m-%d-%H%M`.tar.gz
BACKUP=${TMPDIR}/${BACKUP_FILE}
UNAME=n5200
PASSWD=n5200
# check for source
if [ ! -d ${SOURCE} ]; then
echo "${APPNAME}: ${SOURCE} not found; exiting" >> ${LOG}
exit 1
fi
# is there a mounted USB device?
mount | grep -q ${DEVICE}
if [ $? -ne 0 ]; then
echo "${APPNAME}: device ${DEVICE} not mounted; skipping local copy" >> ${LOG}
SKIPLOCAL=true
fi
MOUNTPOINT=`mount | grep ${DEVICE} | cut -d' ' -f3`
# do we have a samba server out there?
/opt/samba/bin/smbclient -N -L ${SHARE} 2>&1 > /dev/null
if [ $? -ne 0 ]; then
echo "${APPNAME}: could not access ${SHARE}; skipping smb copy" >> ${LOG}
SKIPSMB=true
fi
if [ -n "${SKIPLOCAL}" -a -n "${SKIPSMB}" ]; then
echo "${APPNAME}: can't find either local or remote destination; exiting" >> ${LOG}
exit 1
fi
trap cleanup 0 1 2 3 6 15
cleanup() {
echo "${APPNAME}: cleanup: rm -f ${BACKUP}" >> ${LOG}
rm -f ${BACKUP}
}
# create the file
( cd ${SOURCE}; tar zcf ${BACKUP} . ) 2>&1 > /dev/null
# copy to exernal USB Drive
if [ -n "${SKIPLOCAL}" ]; then
echo "${APPNAME}: COPY to USB: SKIPPED" >> ${LOG}
else
echo "${APPNAME}: COPY to USB: cp ${BACKUP} ${MOUNTPOINT}" >> ${LOG}
cp ${BACKUP} ${MOUNTPOINT}
fi
# push to SMB server host
if [ -n "${SKIPSMB}" ]; then
echo "${APPNAME}: SMB PUSH: SKIPPED" >> ${LOG}
else
echo "${APPNAME}: SMB PUSH: /opt/samba/bin/smbclient -U ${UNAME}%${PASSWD} ${SHARE} -c \"put ${BACKUP} ${BACKUP_FILE}\"" >> ${LOG}
/opt/samba/bin/smbclient -U ${UNAME}%${PASSWD} ${SHARE} \
-c "put ${BACKUP} ${BACKUP_FILE}" 2>&1 > /dev/null
fi
echo "${APPNAME}: finished at `date`..." >> ${LOG}
exit 0
I put this script on the filesystem at /raid/data/LOCAL/bin (and I have also made the directory /raid/data/LOCAL/tmp).
I run this script under cron:
30 3 * * * /raid/data/LOCAL/bin/backup.sh /raid/data/alpheratz //mss-022c5f/n5200 /dev/sdc1
NB: it is necessary to edit the crontab in /app/cfg/crond.conf to ensure persistence across reboots, AS WELL AS to establish this line into the existing system via the command: crontab -e.
Note that this ALSO backs up to the USB disk on /dev/sdc1 (healthy paranoia at work here...)
I backup about 9Gb nightly with this.
There are actually a LOT of example scripts to do this sort of thing with smbclient on the 'net'...this is just mine, FYI.
Cheers,
Alph