-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbackup_assets.sh
executable file
·60 lines (50 loc) · 1.68 KB
/
backup_assets.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
59
60
#!/bin/bash
# Backup Assets
#
# Backup local assets
#
# @author nystudio107
# @copyright Copyright (c) 2017 nystudio107
# @link https://nystudio107.com/
# @package craft-scripts
# @since 1.1.0
# @license MIT
# Get the directory of the currently executing script
DIR="$(dirname "${BASH_SOURCE[0]}")"
# Include files
INCLUDE_FILES=(
"common/defaults.sh"
".env.sh"
"common/common_env.sh"
)
for INCLUDE_FILE in "${INCLUDE_FILES[@]}"
do
if [[ ! -f "${DIR}/${INCLUDE_FILE}" ]] ; then
echo "File ${DIR}/${INCLUDE_FILE} is missing, aborting."
exit 1
fi
source "${DIR}/${INCLUDE_FILE}"
done
# Set the backup directory paths
BACKUP_ASSETS_DIR_PATH="${LOCAL_BACKUPS_PATH}${LOCAL_DB_NAME}/${ASSETS_BACKUP_SUBDIR}/"
BACKUP_CRAFT_DIR_PATH="${LOCAL_BACKUPS_PATH}${LOCAL_DB_NAME}/${CRAFT_BACKUP_SUBDIR}/"
# Make sure the asset backup directory exists
echo "Ensuring backup directory exists at '${BACKUP_ASSETS_DIR_PATH}'"
mkdir -p "${BACKUP_ASSETS_DIR_PATH}"
# Backup the asset dir files via rsync
for DIR in "${LOCAL_ASSETS_DIRS[@]}"
do
rsync -F -L -a -z --progress "${LOCAL_ASSETS_PATH}${DIR}" "${BACKUP_ASSETS_DIR_PATH}"
echo "*** Backed up assets from ${LOCAL_ASSETS_PATH}${DIR}"
done
# Make sure the Craft files backup directory exists
echo "Ensuring backup directory exists at '${BACKUP_CRAFT_DIR_PATH}'"
mkdir -p "${BACKUP_CRAFT_DIR_PATH}"
# Backup the Craft-specific dir files via rsync
for DIR in "${LOCAL_CRAFT_FILE_DIRS[@]}"
do
rsync -F -L -a -z --progress "${LOCAL_CRAFT_FILES_PATH}${DIR}" "${BACKUP_CRAFT_DIR_PATH}"
echo "*** Backed up assets from ${LOCAL_CRAFT_FILES_PATH}${DIR}"
done
# Normal exit
exit 0