-
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.
chore: support importing/exporting uploads folder
- ignore folder used for staging upload imports and exports - add script for exporting/backing up uploads - update naming convention for import/export npm scripts - add script to import uploads - group sql dumps and uploads zip files in sync folder - support simultaneous named exports/backups
- Loading branch information
Showing
8 changed files
with
84 additions
and
26 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
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
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
Empty 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
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,29 @@ | ||
#!/bin/bash | ||
|
||
export $(grep -v '^#' .env | xargs) | ||
|
||
timestamp=$(date -u +%Y-%m-%dT%H-%M-%S_%Z) | ||
path='sync/uploads/exports' | ||
prefix='uploads-export' | ||
|
||
if [ $BACKUP ] | ||
then | ||
path='sync/uploads/backups' | ||
prefix='uploads-backup' | ||
fi | ||
|
||
dirname=$prefix-$timestamp | ||
filename=../$prefix-$timestamp.tar.gz | ||
|
||
if [ $1 ] | ||
then | ||
dirname=$1-$timestamp | ||
filename=../$1-$timestamp.tar.gz | ||
fi | ||
|
||
mkdir -p $path/$dirname | ||
cp -rv uploads/ $path/$dirname | ||
cd $path/$dirname | ||
tar -czf $filename . | ||
cd .. | ||
rm -rf $dirname |
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
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 @@ | ||
#!/bin/bash | ||
|
||
export $(grep -v '^#' .env | xargs) | ||
|
||
# copy the most recent .tar.gz file in the sync/uploads folder for import | ||
cp "$(ls -t sync/uploads/*.tar.gz | head -1)" sync/uploads/uploads-import.tar.gz | ||
if [ $? -ne 0 ] | ||
then | ||
echo "There must be at least one .tar.gz file in the sync/uploads folder to import" | ||
echo "Skipping uploads import" | ||
exit 0 | ||
fi | ||
|
||
rm -rf uploads/* | ||
mkdir -p uploads | ||
tar -zxvf sync/uploads/uploads-import.tar.gz -C uploads | ||
rm sync/uploads/uploads-import.tar.gz | ||
|
||
mkdir -p sync/uploads/previous-imports | ||
mv sync/uploads/*.tar.gz sync/uploads/previous-imports |