-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.in
66 lines (66 loc) · 1.66 KB
/
backup.in
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
#
# $Id: backup.in,v 1.9 2024-07-08 08:08:46+05:30 Cprogrammer Exp mbhangui $
#
HOST=$(uname -n)
if [ -z "$DEST" ] ; then
exit 0
fi
if [ ! -d $DEST/backup ] ; then
echo "$DEST/backup doesn't exist" 1>&2
exit 1
fi
if [ -n "$BACKUP" -a -n "$DEST" ] ; then
if [ ! -d $DEST/backup/$HOST ] ; then
mkdir -p $DEST/backup/$HOST
if [ $? -ne 0 ] ; then
exit 1
fi
fi
for i in $BACKUP
do
d=$(dirname $i)
if [ ! -d $DEST/backup/$HOST"$d" ] ; then
mkdir -p $DEST/backup/$HOST"$d"
fi
if [ -n "$RSYNC_OPTIONS" ] ; then
rsync "$RSYNC_OPTIONS" --delete $i $DEST/backup/$HOST"$d"
else
rsync -alptgomHE --delete $i $DEST/backup/$HOST"$d"
fi
echo "backup done for $i rsync status=$?"
done
fi
exit 0
#
# $Log: backup.in,v $
# Revision 1.9 2024-07-08 08:08:46+05:30 Cprogrammer
# display rsync status on exit
#
# Revision 1.8 2024-04-28 12:25:27+05:30 Cprogrammer
# added RSYNC_OPTIONS variable to pass options to rsync
#
# Revision 1.7 2024-03-14 16:34:46+05:30 Cprogrammer
# transfer files with original directory into dest
#
# Revision 1.7 2024-03-08 19:49:17+05:30 Cprogrammer
# transfer files with original directory into dest
#
# Revision 1.6 2022-06-30 01:27:55+05:30 Cprogrammer
# exit if DEST is not set
#
# Revision 1.5 2021-09-29 19:38:02+05:30 Cprogrammer
# reverted backup script to v1.4
#
# Revision 1.4 2021-04-13 15:54:41+05:30 Cprogrammer
# check for mkdir error
#
# Revision 1.3 2021-04-13 15:29:23+05:30 Cprogrammer
# append hostname to backup directory
#
# Revision 1.2 2021-04-01 20:52:00+05:30 Cprogrammer
# use absolute paths in BACKUP env variable
#
# Revision 1.1 2020-08-31 22:55:51+05:30 Cprogrammer
# Initial revision
#