-
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.
add tzdata package and update echo statements
- Loading branch information
1 parent
9aed61c
commit b77d613
Showing
4 changed files
with
50 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
#!/bin/bash | ||
|
||
export TZ=${TZ:-"UTC"} | ||
|
||
echof() { | ||
builtin echo -e "$(date +"%Y-%m-%dT%H:%M:%S.000%z")\t$*" | ||
} | ||
|
||
if [ "$USE_MONGOEXPORT" == "true" ]; then | ||
echo "Using mongoexport" | ||
echof "using mongoexport" | ||
bash mongoexport-rclone.sh | ||
else | ||
echo "Using mongodump" | ||
echof "using mongodump" | ||
bash mongodump-rclone.sh | ||
fi | ||
fi |
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 |
---|---|---|
@@ -1,64 +1,63 @@ | ||
#!/bin/bash | ||
|
||
echof() { | ||
builtin echo -e "$(date +"%Y-%m-%dT%H:%M:%S.000%z")\t$*" | ||
} | ||
|
||
RCLONE_CONFIG=$RCLONE_CONFIG | ||
RCLONE_CONFIG_FILE="/config/rclone/rclone.conf" | ||
|
||
# if RCLONE_CONFIG file does not exist and RCLONE_CONFIG environment variable is not set | ||
if [ ! -f "$RCLONE_CONFIG_FILE" ] && [ -z "$RCLONE_CONFIG" ]; then | ||
echo "Error: rclone.conf file does not exist and RCLONE_CONFIG environment variable is not set" | ||
exit 1 | ||
echof "Error: rclone.conf file does not exist and RCLONE_CONFIG environment variable is not set" | ||
exit 1 | ||
fi | ||
|
||
RCLONE_REMOTE=${RCLONE_REMOTE:-"default"} | ||
|
||
if [ ! -f "$RCLONE_CONFIG_FILE" ]; then | ||
echo "rclone.conf file does not exist, creating it ($RCLONE_CONFIG_FILE)" | ||
mkdir -p ~/.config/rclone | ||
echo "[$RCLONE_REMOTE]" > $RCLONE_CONFIG_FILE | ||
echo -e "$RCLONE_CONFIG" >> $RCLONE_CONFIG_FILE | ||
echof "rclone.conf file does not exist, creating it ($RCLONE_CONFIG_FILE)" | ||
mkdir -p ~/.config/rclone | ||
echof "[$RCLONE_REMOTE]" >$RCLONE_CONFIG_FILE | ||
echof -e "$RCLONE_CONFIG" >>$RCLONE_CONFIG_FILE | ||
fi | ||
|
||
RCLONE_ARGS=${RCLONE_ARGS:-""} | ||
|
||
RCLONE_ARGS="$RCLONE_ARGS --config $RCLONE_CONFIG_FILE" | ||
RCLONE_REMOTE_PATH=${RCLONE_REMOTE_PATH:-"/"} | ||
|
||
|
||
MONGODUMP_ARGS=${MONGODUMP_ARGS:-""} | ||
|
||
FILENAME=${FILENAME:-"mongodb"} | ||
|
||
if [ -n "$MONGO_DB" ]; then | ||
MONGODUMP_ARGS="$MONGODUMP_ARGS -d $MONGO_DB" | ||
MONGODUMP_ARGS="$MONGODUMP_ARGS -d $MONGO_DB" | ||
fi | ||
|
||
if [ -n "$MONGO_COLLECTION" ]; then | ||
MONGODUMP_ARGS="$MONGODUMP_ARGS -c $MONGO_COLLECTION" | ||
MONGODUMP_ARGS="$MONGODUMP_ARGS -c $MONGO_COLLECTION" | ||
fi | ||
|
||
|
||
FILENAME_TIMESTAMP=${FILENAME_TIMESTAMP:-"true"} | ||
|
||
if [ "$FILENAME_TIMESTAMP" = "true" ]; then | ||
FILENAME="$FILENAME-$(date "+%H-%M-%S-%F")" | ||
FILENAME="$FILENAME-$(date "+%H-%M-%S-%F")" | ||
fi | ||
|
||
OUTPUT_FILE="$FILENAME.archive" | ||
|
||
# if --gzip is in MONGODUMP_ARGS, add .gz to the file name | ||
if [[ $MONGODUMP_ARGS == *"--gzip"* ]]; then | ||
OUTPUT_FILE="$OUTPUT_FILE.gz" | ||
OUTPUT_FILE="$OUTPUT_FILE.gz" | ||
fi | ||
|
||
|
||
echo "Dumping database to $OUTPUT_FILE" | ||
echo "mongodump options: $MONGODUMP_ARGS" | ||
echo "rclone options: $RCLONE_ARGS" | ||
echof "dumping database to $OUTPUT_FILE" | ||
echof "mongodump options: $MONGODUMP_ARGS" | ||
echof "rclone options: $RCLONE_ARGS" | ||
|
||
if [ -n "$MONGO_URI" ]; then | ||
echo "Using MONGO_URI environment variable" | ||
MONGODUMP_ARGS="$MONGODUMP_ARGS --uri=$MONGO_URI" | ||
echof "Using MONGO_URI environment variable for connection with MongoDB" | ||
MONGODUMP_ARGS="$MONGODUMP_ARGS --uri=$MONGO_URI" | ||
fi | ||
|
||
mongodump $MONGODUMP_ARGS --archive | \ | ||
rclone rcat $RCLONE_ARGS $RCLONE_REMOTE:"$RCLONE_REMOTE_PATH"/"$OUTPUT_FILE" | ||
mongodump $MONGODUMP_ARGS --archive | | ||
rclone rcat $RCLONE_ARGS $RCLONE_REMOTE:"$RCLONE_REMOTE_PATH"/"$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