dms-backup.sh
942 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
/sbin/umount $LOCAL_MOUNT
# clear the backup mount point
/bin/rm -rf $LOCAL_MOUNT
/bin/mkdir -p $LOCAL_MOUNT
# mount the server
/sbin/mount_smbfs -N "$BACKUP_SERVER" $LOCAL_MOUNT
# tar up the cvs repository
archive=mrc_dms_`date +%Y-%m-%d`.tgz
/usr/bin/tar czvf /tmp/$archive $BACKUP_FROM
# copy to backup server
/bin/cp /tmp/$archive "$BACKUP_TO"
# check that its there
/bin/ls -al "$BACKUP_TO"
# clean up
/bin/rm /tmp/$archive
# disconnect twice (for safety and because the first try consistently doesn't work)
/sbin/umount $LOCAL_MOUNT
/sbin/umount $LOCAL_MOUNT
exit