forked from ezsystems/ezplatform-com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump_storage.sh
58 lines (43 loc) · 1.27 KB
/
dump_storage.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Incorrect number of arguments passed."
exit
fi
if [ -z "$1" ]
then
echo "Incorrect value of first argument passed."
exit
fi
if [ -z "$2" ]
then
echo "Incorrect value of second argument passed."
exit
fi
TMP_WORKING_DIR=$1
DIRECTORY_PATH=$2
ARCHIVE_EXTENSIONS="*.bz2 *.gz"
BACKUP_DIRECTORY="backup"
README_FILE="README.txt"
ARCHIVE_PATH=${DIRECTORY_PATH}/web/dumps/ezplatform_page_storage.tar.bz2
SOURCE_PATH=${DIRECTORY_PATH}/web/var/site/storage/
PACKAGES_PATH="original/application"
ALIASES_PATH="images/_aliases"
mkdir ${TMP_WORKING_DIR}
echo "Copying files."
rsync -a ${SOURCE_PATH} ${TMP_WORKING_DIR} --exclude=${ALIASES_PATH} --exclude=${PACKAGES_PATH}
mkdir ${TMP_WORKING_DIR}/${PACKAGES_PATH}
cd ${SOURCE_PATH}/${PACKAGES_PATH}
echo "Creating text file."
echo "Please download archive from http://ezplatform.com" > ${README_FILE}
echo "Creating archives."
for archive in ${ARCHIVE_EXTENSIONS}
do
tar -cjf "${TMP_WORKING_DIR}/${PACKAGES_PATH}/${archive}" ${README_FILE}
done
echo "Creating dump."
tar --exclude=${BACKUP_DIRECTORY} --exclude=${README_FILE} -cjf ${ARCHIVE_PATH} -C ${TMP_WORKING_DIR} .
echo "Cleaning."
rm -R ${README_FILE}
rm -R ${TMP_WORKING_DIR}
echo "Done."