fixed script
This commit is contained in:
parent
3dd4c7c861
commit
0a16a3f2e7
@ -1,32 +1,32 @@
|
|||||||
#!/bin/sh
|
#!/use/bin/env sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
[ -z "${RCLONE_REMOTE}" ] && echo "\$RCLONE_REMOTE is not set" && exit 1
|
[ -z "${RCLONE_REMOTE}" ] && echo "\$RCLONE_REMOTE is not set" && exit 1
|
||||||
[ -z "${RCLONE_CONFIG}" ] && echo "\$RCLONE_CONFIG is not set" && exit 1
|
[ -z "${RCLONE_CONFIG}" ] && echo "\$RCLONE_CONFIG is not set" && exit 1
|
||||||
|
|
||||||
if [ -z "${ENC_PASSWORD}" ]
|
if [ -z "${ENC_PASSWORD}" ]; then
|
||||||
then
|
|
||||||
RESTIC_PASSWORD="${ENC_PASSWORD}"
|
RESTIC_PASSWORD="${ENC_PASSWORD}"
|
||||||
else if [ -z "${ENC_PASSWORD_FILE}" ]
|
elif [ -z "${ENC_PASSWORD_FILE}" ]; then
|
||||||
RESTIC_PASSWORD=$(cat $ENC_PASSWORD_FILE)
|
RESTIC_PASSWORD=$(cat "$ENC_PASSWORD_FILE")
|
||||||
else
|
else
|
||||||
echo "\$ENC_PASSWORD or \$ENC_PASSWORD_FILE is not set" && exit 1
|
echo "\$ENC_PASSWORD or \$ENC_PASSWORD_FILE is not set" && exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${MYSQL_PASSWORD}" ]
|
if [ -z "${MYSQL_PASSWORD}" ]; then
|
||||||
then
|
|
||||||
MYSQL_PASSWORD_ACTUAL="${MYSQL_PASSWORD}"
|
MYSQL_PASSWORD_ACTUAL="${MYSQL_PASSWORD}"
|
||||||
else if [ -z "${MYSQL_PASSWORD_FILE}" ]
|
elif [ -z "${MYSQL_PASSWORD_FILE}" ]; then
|
||||||
MYSQL_PASSWORD_ACTUAL=$(cat $MYSQL_PASSWORD_FILE)
|
MYSQL_PASSWORD_ACTUAL=$(cat "$MYSQL_PASSWORD_FILE")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p /backup/sqlDump
|
mkdir -p /backup/sqlDump
|
||||||
|
|
||||||
for db in ${MYSQL_DUMP_DB//,/ }
|
for db in $(echo "$MYSQL_DUMP_DB" | sed 's/,/\n/g')
|
||||||
do
|
do
|
||||||
echo "Dumping db: $db"
|
echo "Dumping db: $db"
|
||||||
mysqldump --compact -P 3306 --host $MYSQL_HOST -u "$MYSQL_USERNAME" "-p$MYSQL_PASSWORD_ACTUAL" "$db" > "/backup/sqlDump/$db.sql"
|
mysqldump --compact -P 3306 --host "$MYSQL_HOST" -u "$MYSQL_USERNAME" "-p$MYSQL_PASSWORD_ACTUAL" "$db" > "/backup/sqlDump/$db.sql"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
export RESTIC_PASSWORD
|
||||||
|
|
||||||
restic -r "rclone:$RCLONE_REMOTE" --verbose backup "/backup"
|
restic -r "rclone:$RCLONE_REMOTE" --verbose backup "/backup"
|
||||||
|
11
init.sh
11
init.sh
@ -1,21 +1,22 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
[ -z "${RCLONE_REMOTE}" ] && echo "\$RCLONE_REMOTE is not set" && exit 1
|
[ -z "${RCLONE_REMOTE}" ] && echo "\$RCLONE_REMOTE is not set" && exit 1
|
||||||
[ -z "${RCLONE_CONFIG}" ] && echo "\$RCLONE_CONFIG is not set" && exit 1
|
[ -z "${RCLONE_CONFIG}" ] && echo "\$RCLONE_CONFIG is not set" && exit 1
|
||||||
|
|
||||||
if [ -z "${ENC_PASSWORD}" ]
|
if [ -z "${ENC_PASSWORD}" ]; then
|
||||||
then
|
|
||||||
RESTIC_PASSWORD="${ENC_PASSWORD}"
|
RESTIC_PASSWORD="${ENC_PASSWORD}"
|
||||||
else if [ -z "${ENC_PASSWORD_FILE}" ]
|
elif [ -z "${ENC_PASSWORD_FILE}" ]; then
|
||||||
RESTIC_PASSWORD=$(cat $ENC_PASSWORD_FILE)
|
RESTIC_PASSWORD=$(cat "$ENC_PASSWORD_FILE")
|
||||||
else
|
else
|
||||||
echo "\$ENC_PASSWORD or \$ENC_PASSWORD_FILE is not set" && exit 1
|
echo "\$ENC_PASSWORD or \$ENC_PASSWORD_FILE is not set" && exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Init new repo"
|
echo "Init new repo"
|
||||||
|
|
||||||
|
export RESTIC_PASSWORD
|
||||||
|
|
||||||
restic -r "rclone:$RCLONE_REMOTE" init
|
restic -r "rclone:$RCLONE_REMOTE" init
|
||||||
|
|
||||||
echo "Created new repo at $RCLONE_REMOTE"
|
echo "Created new repo at $RCLONE_REMOTE"
|
||||||
|
Loading…
Reference in New Issue
Block a user