-
Notifications
You must be signed in to change notification settings - Fork 0
/
backupsite.sh
33 lines (26 loc) · 953 Bytes
/
backupsite.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
# web root /var/www/
# backups folder /var/www/backups
alias webroot=/var/www/
function backupsite(){
if [ -d ${webroot}$1 ]; then
cd /var/www/webroot/
DATE=`date +%Y_%m_%d_%H%M%S`
orig=$1
FOLDER=${orig//\//.}
FILENAME=${FOLDER}_${DATE}.tar.gz
tar -zcvf ${webroot}backups/${FILENAME} $1
printf "\e[1;34m\t .. ... .... .:::: :::::: ::::::: :|||||||||||||||: ::::::: :::::: ::::. .... ... ..\n"
printf "\e[1;34m\t $1 Successfully backed up. \e[32m ${webroot}${FILENAME} \n"
printf "\e[1;34m\t \e[0m \n"
sudo chmod 775 ${webroot}backups/${FILENAME}
fi
}
## Examples and usage ###
## Full folder backup
## backupsite examplesite
## Sub Directory backup
## examplesite/folder1/img
##
## backupsite examplesite/folder1/img
##
##