Koozali.org: home of the SME Server

Can I Schedule a Backup-to-Desktop ?

Adam

Can I Schedule a Backup-to-Desktop ?
« on: September 14, 2002, 04:02:51 AM »
Hello all,

is it possible to schedule a backup to Desktop ? I want to schedule it to run nightly so that I can back it up on our Win2K Server as part of it's *normal* backup process.

cheers,

Adam

Ian Wells

Re: Can I Schedule a Backup-to-Desktop ?
« Reply #1 on: September 14, 2002, 01:24:15 PM »
What I do is use the following.

Thanks to Filippo Carletti's post on devinfo for the original
desktop backup script.

I have made a crontab file for root, shown as mycronfile below.
by usng 'crontab mycronfile' whilst logged in as root tasks listed
in this file are executed by cron.

The part shown below will start the backup to desktop at 5.01am daily

<--- This is part of mycronfile --->
# Allow one minute then backup the server
1 5 * * * /usr/bin/desktop_backup.sh
<--- end --->

Note that it calls a shell script (also below) which I put into /usr/bin
and you need to supply the hostname, the share, username and password.

I think that this method could be improved as putting the
username and password in the shell script is not nice.
Also as it stand they are also logged.
Currently this is OK for my set-up but it I want to improve it later.

You may want to check that this backs up exactly what you want as
I have customised it to meet *my* needs.

Firstly the date appears in the backup filename.

Secondly check what you really want backed up, and add any additional directories
eg under /opt, just before the etc/smbpasswd

I believe, but cannot confirm, that this matches the 5.5 release.

I advise that you test this out before relying on it. All I can say is that
I have used it (backup & restored) on all released SME 5.x versions (not 5.6alpha)


<--- desktop.sh starts here --->
#!/bin/sh


if [ $# -lt 4 ]; then
   echo "Usage: $(basename $0) "
   exit 1;
fi


SMBHOST=$1
SMBSHARE=$2
SMBUSER=$3
SMBPASS=$4

#TIME is the date in mmmddyyy format 'Apr132003' this is used in the filename
TIME=/bin/date | /bin/awk '{print $2$3$6}'

#FILENAME is the full filename of the backup, traditionally smeserver.tgz
FILENAME="smeserver${TIME}.tgz"

/sbin/e-smith/signal-event mysql-delete-dumps
/sbin/e-smith/signal-event mysql-dump-tables

/bin/tar --directory / --create home/e-smith etc/e-smith/templates-custom etc/e-smith/templates-user-custom etc/passwd etc/shadow etc/group etc/gshadow etc/ssh root/.ssh root etc/smbpasswd --file=- | gzip | ( echo put - "${FILENAME}"; cat ) | smbclient "//${SMBHOST}/${SMBSHARE}" "${SMBPASS}" -U "${SMBUSER}" &>/dev/null

/sbin/e-smith/signal-event mysql-delete-dumps
<--- desktop.sh ends here --->

Adam

Re: Can I Schedule a Backup-to-Desktop ?
« Reply #2 on: September 14, 2002, 01:28:57 PM »
Thanks Ian,

I'll definately give this a go. I'll test it thoroughly before I start relying on it - as per your advice.

cheers,

Adam

Ian Wells

Re: Can I Schedule a Backup-to-Desktop ?
« Reply #3 on: September 14, 2002, 04:48:10 PM »
I just checked my 5.1.2 box, and you can check what the backup to desktop does by looking at /etc/e-smith/web/functions/backup.

The directory list can be seen in @directories

To this I have added /root (which was also added in 5.5 I believe), however omit the leading / so this becomes just root.

If you have a standard install this should therefore be identical to the normal Mitel version. (I don't have my 5.5 or 5.6 servers on at the moment so cannot verify this)

If you have a non-standard server you may have application data elsewhere. For instance I had installed extra applications which went into /opt. Obviously neither the Mitel backup nor the script I posted would backup application data in this case.

Hopefully you can see that this can be added easily to the script by adding entries like opt/my_application_data_directory into the script before the etc/smbpasswd entry

Ian

Ian Wells

Re: Can I Schedule a Backup-to-Desktop ?
« Reply #4 on: December 08, 2002, 12:52:32 PM »
The Backup-to-Desktop script given above does not work on SME 5.6b7 as the events used to dump the MySQL database have changed. Without the change below the MySQL database is not backed up.

Luckily the changes are small, and can be determined from looking at the new 'backup' in SME 5.6.

The changes necessary are to replace the previous signal-event lines with the ones below.

/sbin/e-smith/signal-event pre-backup

/bin/tar ... this line as before

/sbin/e-smith/signal-event post-backup

Lawrence

Re: Can I Schedule a Backup-to-Desktop ?
« Reply #5 on: February 15, 2003, 05:15:06 PM »
I've been using this backup script for a while on my 5.5 box without any problems.  I have recently upgraded to 5.6.  I noticed the changes to the MySQL events, and corrected the script.  However, I've been receiving the following errors:

/root/desktop_backup.sh: line 20: 29702 Broken pipe             cat

/root/desktop_backup.sh: line 20: 29745 Broken pipe             cat


/bin/tar: home/e-smith/files/users/pager/Maildir/cur/1045290151.30301_2.esmithh,U=1278,W=1229\:2,: Cannot stat: No such file or directory
/bin/tar: Error exit delayed from previous errors

/bin/tar: home/e-smith/files/users/pager/Maildir/.imaplock: Cannot stat: No such file or directory
/bin/tar: Error exit delayed from previous errors

Any ideas?

Thanks,
Lawrence