added entrypoint
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Djeeberjr 2022-03-27 01:31:46 +01:00
parent 505d6d4d44
commit 5f8248d236
7 changed files with 57 additions and 13 deletions

3
.gitignore vendored
View File

@ -10,4 +10,5 @@
!interactive.sh
!mysql.sh
!.dockerignore
!restore.sh
!restore.sh
!entrypoint.sh

View File

@ -4,14 +4,14 @@ RUN apk add --no-cache mysql-client rclone bash fuse postgresql-client
RUN mkdir /app && mkdir /config
COPY entrypoint.sh /app/entrypoint.sh
COPY setup.sh /app/setup.sh
COPY backup.sh /app/backup.sh
COPY interactive.sh /app/interactive.sh
COPY restore.sh /app/restore.sh
# COPY mysql.sh /app/mysql.sh
WORKDIR /config
VOLUME /config
ENTRYPOINT [ "/app/backup.sh" ]
ENTRYPOINT [ "/app/entrypoint.sh" ]

View File

@ -61,5 +61,6 @@ docker run \
--network "dbNet" \
-v "/var/docker/backup:/config" \
$BACKUP_VOL \
djeeberjr/backup
djeeberjr/backup \
backup
```

View File

@ -2,8 +2,6 @@
set -e
. /app/setup.sh
mkdir -p /backup/sqlDump
for db in $(echo "$MYSQL_DUMP_DB" | sed 's/,/\n/g')

42
entrypoint.sh Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env sh
set -e
COMMAND="$1"
# print usage if no command is given
if [ -z "$COMMAND" ]; then
echo "Usage: $0 <command>"
echo "Available commands:"
echo " backup"
echo " restore"
echo " init TODO"
echo " interactive"
exit 1
fi
. /app/setup.sh
case "$COMMAND" in
backup)
# backup
/app/backup.sh
;;
restore)
# restore
/app/restore.sh
;;
init)
# init
# TODO: implement
/app/init.sh
;;
interactive)
# interactive
/app/interactive.sh
;;
*)
echo "Unknown command: $COMMAND"
exit 1
;;
esac

View File

@ -1,6 +1,4 @@
#!/usr/bin/env bash
. /app/setup.sh
#!/usr/bin/env bash
mkdir -p /restore
@ -12,7 +10,7 @@ echo "########################"
echo "rclone config # edit/add remote"
echo "restic init # create new repo"
echo "restic snapshots # list backups"
echo "restic -restore latest --target /restore # restore latest backup to /restore"
echo "restic restore latest --target /restore # restore latest backup to /restore"
echo "restic dump latest /backup/sqlDump/dbname.sql # Dump sql dump to console"
echo "/app/backup.sh # Create backup"
echo "/app/mysql.sh # Open mysql client"

View File

@ -1,7 +1,11 @@
#!/usr/bin/env bash
. /app/setup.sh
VOLUMES=$(find /backup -maxdepth 1 -type d -printf '%f\n' | tail -n +2)
#loop volumes
for VOLUME in $VOLUMES; do
echo "Restoring $VOLUME"
restic -v restore latest --include "/backup/$VOLUME"
done
# find . -maxdepth 1 -type d -printf '%f\n' | tail -n +2
restic restore latest