forked from ramirojoaquin/vestacp-borg-incremental-backups
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtar-user.sh
executable file
·39 lines (29 loc) · 816 Bytes
/
tar-user.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
#!/bin/bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source $CURRENT_DIR/config.ini
# This script will restore a web domain from incremental backup
USAGE='tar-user.sh user [date]'
# Assign arguments
TIME=$2
USER=$1
# Set script start time
START_TIME=`date +%s`
# Set user repository
USER_REPO=$REPO_USERS_DIR/$USER
##### Validations #####
if [ -z $1 ]; then
echo "!!!!! This script needs at least 3 arguments. Backup date, user name and web domain. Dadabase is optional"
echo "---"
echo "Usage example:"
echo $USAGE
exit 1
fi
if [ -z $2 ]; then
borg list $USER_REPO
exit 1
fi
borg export-tar $USER_REPO::$TIME $BACKUP_DIR/$USER.$TIME.tar
END_TIME=`date +%s`
RUN_TIME=$((END_TIME-START_TIME))
echo "-- Execution time: $(date -u -d @${RUN_TIME} +'%T')"
echo