dms-backup.sh
884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/local/bin/bash
#
# backup.sh - archives and copies project cvs root to windoze file server
# todo: return code checking, mail status
# define paths
BACKUP_USER=jambackup
BACKUP_SERVER="//$BACKUP_USER@Jam001/JAM Backups"
LOCAL_MOUNT=/tmp/backup
BACKUP_FROM=/usr/local/cvsroot
BACKUP_TO=/tmp/backup/Backups\ to\ tape/
# check that we're not mounted already
umount $LOCAL_MOUNT
# clear the backup mount point
rm -rf $LOCAL_MOUNT
mkdir -p $LOCAL_MOUNT
# mount the server
mount_smbfs -N "$BACKUP_SERVER" $LOCAL_MOUNT
# tar up the cvs repository
archive=mrc_dms_`date +%Y-%m-%d`.tgz
tar czvf /tmp/$archive $BACKUP_FROM
# copy to backup server
cp /tmp/$archive "$BACKUP_TO"
# check that its there
ls -al "$BACKUP_TO"
# clean up
rm /tmp/$archive
# disconnect twice (for safety and because the first try consistently doesn't work)
umount $LOCAL_MOUNT
umount $LOCAL_MOUNT
exit