too lazy to list things
This commit is contained in:
parent
5f8248d236
commit
818e58f179
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,14 +0,0 @@
|
|||||||
*
|
|
||||||
!.gitignore
|
|
||||||
!Dockerfile
|
|
||||||
!docker-compose.yml
|
|
||||||
!backup.sh
|
|
||||||
!README.md
|
|
||||||
!.drone.yml
|
|
||||||
!init.sh
|
|
||||||
!setup.sh
|
|
||||||
!interactive.sh
|
|
||||||
!mysql.sh
|
|
||||||
!.dockerignore
|
|
||||||
!restore.sh
|
|
||||||
!entrypoint.sh
|
|
@ -4,11 +4,7 @@ RUN apk add --no-cache mysql-client rclone bash fuse postgresql-client
|
|||||||
|
|
||||||
RUN mkdir /app && mkdir /config
|
RUN mkdir /app && mkdir /config
|
||||||
|
|
||||||
COPY entrypoint.sh /app/entrypoint.sh
|
COPY src/ /app/
|
||||||
COPY setup.sh /app/setup.sh
|
|
||||||
COPY backup.sh /app/backup.sh
|
|
||||||
COPY interactive.sh /app/interactive.sh
|
|
||||||
COPY restore.sh /app/restore.sh
|
|
||||||
|
|
||||||
WORKDIR /config
|
WORKDIR /config
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ Environment variables:
|
|||||||
|
|
||||||
`RESTIC_PASSWORD` or `RESTIC_PASSWORD_FILE` password for the repo
|
`RESTIC_PASSWORD` or `RESTIC_PASSWORD_FILE` password for the repo
|
||||||
|
|
||||||
`RCLONE_CONFIG_FILE` content of the rclone config.
|
`RCLONE_CONFIG_CONTENT` content of the rclone config.
|
||||||
|
|
||||||
For the database:
|
For the database:
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ Use the `/app/init.sh` script to init a new remote.
|
|||||||
|
|
||||||
# Directorys
|
# Directorys
|
||||||
|
|
||||||
`/config` Contains the rclone config.
|
`/config` Contains the rclone config. Can also be passed as env var.
|
||||||
`/backup` Contains the mounted volumes as read only
|
`/backup` Contains the mounted volumes as read only
|
||||||
`/restore` Contains volumes to restore
|
`/restore` Contains volumes to restore
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ Here is an example of the script i use to backup my volumes:
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# get all volumes with the "backup.enable" lable on it
|
# get all volumes with the "backup.enable" label on it
|
||||||
BACKUP_VOL=$(docker volume ls --filter "label=backup.enable" --format '-v {{ .Name }}:/backup/{{ .Name }}:ro ')
|
BACKUP_VOL=$(docker volume ls --filter "label=backup.enable" --format '-v {{ .Name }}:/backup/{{ .Name }}:ro ')
|
||||||
|
|
||||||
docker run \
|
docker run \
|
||||||
|
@ -4,3 +4,4 @@ services:
|
|||||||
backup:
|
backup:
|
||||||
build: .
|
build: .
|
||||||
image: djeeberjr/backup
|
image: djeeberjr/backup
|
||||||
|
command: init
|
@ -17,3 +17,5 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
restic --verbose backup "/backup"
|
restic --verbose backup "/backup"
|
||||||
|
|
||||||
|
restic --verbose prune --keep-last 3
|
@ -10,11 +10,17 @@ if [ -z "$COMMAND" ]; then
|
|||||||
echo "Available commands:"
|
echo "Available commands:"
|
||||||
echo " backup"
|
echo " backup"
|
||||||
echo " restore"
|
echo " restore"
|
||||||
echo " init TODO"
|
echo " init"
|
||||||
echo " interactive"
|
echo " interactive"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# if command is init
|
||||||
|
if [ "$COMMAND" = "init" ]; then
|
||||||
|
/app/init.sh
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
. /app/setup.sh
|
. /app/setup.sh
|
||||||
|
|
||||||
case "$COMMAND" in
|
case "$COMMAND" in
|
||||||
@ -26,15 +32,14 @@ case "$COMMAND" in
|
|||||||
# restore
|
# restore
|
||||||
/app/restore.sh
|
/app/restore.sh
|
||||||
;;
|
;;
|
||||||
init)
|
|
||||||
# init
|
|
||||||
# TODO: implement
|
|
||||||
/app/init.sh
|
|
||||||
;;
|
|
||||||
interactive)
|
interactive)
|
||||||
# interactive
|
# interactive
|
||||||
/app/interactive.sh
|
/app/interactive.sh
|
||||||
;;
|
;;
|
||||||
|
list)
|
||||||
|
# list
|
||||||
|
/app/list.sh
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown command: $COMMAND"
|
echo "Unknown command: $COMMAND"
|
||||||
exit 1
|
exit 1
|
43
src/init.sh
Executable file
43
src/init.sh
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# if RCLONE_CONFIG_CONTENT is empty and no config file was found
|
||||||
|
if [ -z "$RCLONE_CONFIG_CONTENT" ] && [ ! -e "${RCLONE_CONFIG:=/config/rclone.conf}" ]; then
|
||||||
|
echo "No rclone config found"
|
||||||
|
rclone --config "${RCLONE_CONFIG:=/config/rclone.conf}" config
|
||||||
|
fi
|
||||||
|
|
||||||
|
RCLONE_REMOTE="$(rclone listremotes | head -1)"
|
||||||
|
|
||||||
|
echo "Using remote: $RCLONE_REMOTE"
|
||||||
|
|
||||||
|
RESTIC_REPOSITORY="rclone:$RCLONE_REMOTE"
|
||||||
|
|
||||||
|
echo "Using repository: $RESTIC_REPOSITORY"
|
||||||
|
|
||||||
|
# if RESTIC_PASSWORD is empty
|
||||||
|
if [ -z "$RESTIC_PASSWORD" ] && [ -z "$RESTIC_PASSWORD_FILE" ]; then
|
||||||
|
echo "Set \$RESTIC_PASSWORD or \$RESTIC_PASSWORD_FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export RCLONE_REMOTE
|
||||||
|
export RESTIC_REPOSITORY
|
||||||
|
|
||||||
|
restic init
|
||||||
|
|
||||||
|
echo "Display rclone config [y/N]?"
|
||||||
|
read -r answer
|
||||||
|
|
||||||
|
# check if answer is yes
|
||||||
|
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
|
||||||
|
rclone --config "${RCLONE_CONFIG:=/config/rclone.conf}" config show
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Environemnt variables:"
|
||||||
|
echo "RCLONE_REMOTE=$RCLONE_REMOTE"
|
||||||
|
echo "RESTIC_PASSWORD=*********"
|
||||||
|
echo "RESTIC_REPOSITORY=$RESTIC_REPOSITORY"
|
||||||
|
echo ""
|
9
src/list.sh
Executable file
9
src/list.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Volumes:"
|
||||||
|
restic ls latest "/backup"
|
||||||
|
|
||||||
|
echo "Snapshots:"
|
||||||
|
restic snapshots latest
|
2
restore.sh → src/restore.sh
Normal file → Executable file
2
restore.sh → src/restore.sh
Normal file → Executable file
@ -5,7 +5,7 @@ VOLUMES=$(find /backup -maxdepth 1 -type d -printf '%f\n' | tail -n +2)
|
|||||||
#loop volumes
|
#loop volumes
|
||||||
for VOLUME in $VOLUMES; do
|
for VOLUME in $VOLUMES; do
|
||||||
echo "Restoring $VOLUME"
|
echo "Restoring $VOLUME"
|
||||||
restic -v restore latest --include "/backup/$VOLUME"
|
restic --verbose restore latest --include "/backup/$VOLUME"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -n "$RCLONE_CONFIG_FILE" ]; then
|
if [ -n "$RCLONE_CONFIG_CONTENT" ]; then
|
||||||
echo "$RCLONE_CONFIG_FILE" > "${RCLONE_CONFIG:=/config/rclone.conf}"
|
echo "$RCLONE_CONFIG_CONTENT" > "${RCLONE_CONFIG:=/config/rclone.conf}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${RCLONE_CONFIG}" ]; then
|
if [ -z "${RCLONE_CONFIG}" ]; then
|
Loading…
Reference in New Issue
Block a user