forked from s9y/additional_plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.sh
executable file
·43 lines (33 loc) · 819 Bytes
/
backup.sh
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
#!/bin/bash
# [backup.sh]
# written 2005/09/27 by Alexander 'dma147' Mieland <[email protected]>
#
function usage {
echo "Usage: ${0} <dir_to_backup> <backupdir> [excludes]"
}
if [ ! "${1}" -o "${1}" == "" ]; then
usage
exit 1
else
DIR_TO_BACKUP="${1}"
fi
if [ ! "${2}" -o "${2}" == "" ]; then
usage
exit 1
else
TARGET_DIR="${2}"
fi
OPT=" --exclude=${TARGET_DIR}"
c=0
for arg in "$@"; do
if [ ${c} -ge 3 ]; then
OPT="${OPT} --exclude=${arg}"
fi
c=$(( ${c} + 1 ))
done
DIR_TO_CHANGE=`echo ${DIR_TO_BACKUP} | sed -e 's/^\(.*\)\/[^\/]*$/\1/'`
DIR_TO_BACKUP=`echo ${DIR_TO_BACKUP} | sed -e 's/^.*\/\([^\/]*\)$/\1/'`
date=`date +%Y-%m-%d-%H-%M`
TAR=`which tar`
PWD=`pwd`
${TAR}${OPT} -czpf ${TARGET_DIR}/${date}_htmlbackup.tar.gz --directory=${DIR_TO_CHANGE} ./${DIR_TO_BACKUP} >/dev/null 2>&1 &