-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport snapshot export/import scripts from D10 image
- Loading branch information
1 parent
bea03d5
commit 4296701
Showing
7 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
|
||
if [ $# -ne 1 ];then | ||
echo "No target location specified." | ||
exit 1 | ||
fi | ||
|
||
mkdir -p "$1" | ||
|
||
OUTPUT_FILE="$1/db.sql" | ||
/scripts/clearDrupalCache.sh > /dev/null 2>&1 | ||
/scripts/sqlDump.sh "$OUTPUT_FILE" | ||
gzip -f "$OUTPUT_FILE" | ||
echo "$OUTPUT_FILE.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
|
||
if [ $# -ne 1 ];then | ||
echo "No target location specified, generating random location." | ||
HASH=$(echo $RANDOM | md5sum | head -c 20; echo) | ||
BASE_PATH='/data-export' | ||
EXPORT_PATH="$BASE_PATH/$HASH" | ||
mkdir -p "$EXPORT_PATH" | ||
chown $NGINX_RUN_USER:$NGINX_RUN_GROUP $EXPORT_PATH | ||
else | ||
EXPORT_PATH="$1" | ||
fi | ||
|
||
# Export Content | ||
/scripts/exportContent.sh "$EXPORT_PATH" | ||
/scripts/exportFiles.sh "$EXPORT_PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
|
||
if [ $# -ne 1 ];then | ||
echo "No target location specified." | ||
exit 1 | ||
fi | ||
|
||
mkdir -p "$1" | ||
|
||
OUTPUT_FILE="$1/files.tar.gz" | ||
/scripts/clearDrupalCache.sh > /dev/null 2>&1 | ||
cd "$DRUPAL_ROOT/sites/default/files" | ||
tar -cvpzf "$1/files.tar.gz" --exclude=*.css --exclude=*.css.gz --exclude=*.js --exclude=*.js.gz --exclude=./php --exclude=./styles . > /dev/null 2>&1 | ||
echo "$OUTPUT_FILE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
|
||
if [ $# -ne 1 ];then | ||
echo "No database file specified!" | ||
exit 1 | ||
elif [ ! -f "$1" ] ; then | ||
echo "$1 does not exist!" | ||
exit 1 | ||
fi | ||
|
||
# Import the content. | ||
EXTRACTED_PATH=$(echo $1 | rev | cut -f 2- -d '.' | rev) | ||
EXTRACTED_FILE=$(basename "$EXTRACTED_PATH") | ||
gunzip -c "$1" > "/tmp/$EXTRACTED_FILE" | ||
echo "Importing $EXTRACTED_FILE" | ||
sh -c "$DRUSH sql-cli < /tmp/$EXTRACTED_FILE" | ||
$DRUSH cr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
|
||
if [ $# -ne 1 ]; then | ||
echo "No import location specified!" | ||
exit 1 | ||
elif [ ! -f "$1/db.sql.gz" ] ; then | ||
echo "$1/db.sql.gz does not exist!" | ||
exit 1 | ||
fi | ||
|
||
# Import Content. | ||
/scripts/importContent.sh "$1/db.sql.gz" | ||
|
||
# (Optionally) Import Files. | ||
if [ -f "$1/files.tar.gz" ] ; then | ||
/scripts/importFiles.sh "$1/files.tar.gz" | ||
fi | ||
|
||
echo 'Success!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env sh | ||
# Note! No private filesystem support. | ||
set -e | ||
|
||
if [ $# -ne 1 ];then | ||
echo "No public filesystem archive specified!" | ||
exit 1 | ||
elif [ ! -f "$1" ] ; then | ||
echo "$1 does not exist!" | ||
exit 1 | ||
fi | ||
|
||
# Import the filesystem archive to the public filesystem. | ||
tar -tzf $1 >/dev/null # Check if the archive is valid. | ||
rm -rf "$DRUPAL_ROOT/sites/default/files/*" | ||
tar -xzf $1 --directory "$DRUPAL_ROOT/sites/default/files/" | ||
/scripts/pre-init.d/71_set_public_file_permissions.sh | ||
/scripts/pre-init.d/72_secure_filesystems.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
|
||
if [ $# -ne 1 ];then | ||
echo "No target specified." | ||
exit 1 | ||
fi | ||
|
||
$DRUSH sql-dump --extra-dump=--no-tablespaces --structure-tables-list="accesslog,batch,cache,cache_*,ctools_css_cache,ctools_object_cache,flood,search_*,history,queue,semaphore,sessions,watchdog" --result-file=$1 |