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
 | 
			
		||||
 | 
			
		||||
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 src/ /app/
 | 
			
		||||
 | 
			
		||||
WORKDIR /config
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -10,7 +10,7 @@ Environment variables:
 | 
			
		||||
 | 
			
		||||
`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:
 | 
			
		||||
 | 
			
		||||
@ -34,7 +34,7 @@ Use the `/app/init.sh` script to init a new remote.
 | 
			
		||||
 | 
			
		||||
# 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
 | 
			
		||||
`/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
 | 
			
		||||
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 ')
 | 
			
		||||
 | 
			
		||||
docker run \
 | 
			
		||||
 | 
			
		||||
@ -3,4 +3,5 @@ version: "3"
 | 
			
		||||
services:
 | 
			
		||||
  backup:
 | 
			
		||||
    build: .
 | 
			
		||||
    image: djeeberjr/backup
 | 
			
		||||
    image: djeeberjr/backup
 | 
			
		||||
    command: init
 | 
			
		||||
@ -17,3 +17,5 @@ do
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
restic --verbose backup "/backup"
 | 
			
		||||
 | 
			
		||||
restic --verbose prune --keep-last 3
 | 
			
		||||
@ -10,11 +10,17 @@ if [ -z "$COMMAND" ]; then
 | 
			
		||||
  echo "Available commands:"
 | 
			
		||||
  echo "  backup"
 | 
			
		||||
  echo "  restore"
 | 
			
		||||
  echo "  init TODO"
 | 
			
		||||
  echo "  init"
 | 
			
		||||
  echo "  interactive"
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# if command is init
 | 
			
		||||
if [ "$COMMAND" = "init" ]; then
 | 
			
		||||
  /app/init.sh
 | 
			
		||||
  exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
. /app/setup.sh
 | 
			
		||||
 | 
			
		||||
case "$COMMAND" in
 | 
			
		||||
@ -26,15 +32,14 @@ case "$COMMAND" in
 | 
			
		||||
    # restore
 | 
			
		||||
    /app/restore.sh
 | 
			
		||||
    ;;
 | 
			
		||||
  init)
 | 
			
		||||
    # init 
 | 
			
		||||
    # TODO: implement
 | 
			
		||||
    /app/init.sh
 | 
			
		||||
    ;;
 | 
			
		||||
  interactive)
 | 
			
		||||
    # interactive
 | 
			
		||||
    /app/interactive.sh
 | 
			
		||||
    ;;
 | 
			
		||||
  list)
 | 
			
		||||
    # list
 | 
			
		||||
    /app/list.sh
 | 
			
		||||
    ;;
 | 
			
		||||
  *)
 | 
			
		||||
    echo "Unknown command: $COMMAND"
 | 
			
		||||
    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
 | 
			
		||||
for VOLUME in $VOLUMES; do
 | 
			
		||||
  echo "Restoring $VOLUME"
 | 
			
		||||
  restic -v restore latest --include "/backup/$VOLUME"
 | 
			
		||||
  restic --verbose restore latest --include "/backup/$VOLUME"
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,8 +2,8 @@
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
if [ -n "$RCLONE_CONFIG_FILE" ]; then 
 | 
			
		||||
    echo "$RCLONE_CONFIG_FILE" > "${RCLONE_CONFIG:=/config/rclone.conf}"
 | 
			
		||||
if [ -n "$RCLONE_CONFIG_CONTENT" ]; then 
 | 
			
		||||
    echo "$RCLONE_CONFIG_CONTENT" > "${RCLONE_CONFIG:=/config/rclone.conf}"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -z "${RCLONE_CONFIG}" ]; then
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user