forked from coop-cloud/backup-bot-two
		
	Fix AWS S3 settings
This commit is contained in:
		
							
								
								
									
										13
									
								
								backup.sh
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								backup.sh
									
									
									
									
									
								
							@ -6,6 +6,8 @@ restic_password_file="${RESTIC_PASSWORD_FILE:?RESTIC_PASSWORD_FILE not set}"
 | 
			
		||||
 | 
			
		||||
restic_host="${RESTIC_HOST:?RESTIC_HOST not set}"
 | 
			
		||||
 | 
			
		||||
backup_path="${BACKUP_DEST:?BACKUP_DEST not set}"
 | 
			
		||||
 | 
			
		||||
ssh_key_file="${SSH_KEY_FILE}"
 | 
			
		||||
s3_key_file="${AWS_SECRET_ACCESS_KEY_FILE}"
 | 
			
		||||
 | 
			
		||||
@ -18,8 +20,9 @@ if [ -n "$ssh_key_file" ] && [ -f "$ssh_key_file" ]; then
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -n "$s3_key_file" ] && [ -f "$s3_key_file" ]; then
 | 
			
		||||
	export "$AWS_SECRET_ACCESS_KEY"="$(cat "${s3_key_file}")"
 | 
			
		||||
	restic_repo="s3:$restic_host:/$server_name"
 | 
			
		||||
	AWS_SECRET_ACCESS_KEY="$(cat "${s3_key_file}")"
 | 
			
		||||
	export AWS_SECRET_ACCESS_KEY
 | 
			
		||||
	restic_repo="s3:$restic_host$server_name"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -z "$restic_repo" ]; then
 | 
			
		||||
@ -27,6 +30,8 @@ if [ -z "$restic_repo" ]; then
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "restic_repo: $restic_repo"
 | 
			
		||||
 | 
			
		||||
# Pre-bake-in some default restic options
 | 
			
		||||
_restic() {
 | 
			
		||||
	# shellcheck disable=SC2068
 | 
			
		||||
@ -36,8 +41,6 @@ _restic() {
 | 
			
		||||
		$@
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
backup_path="${BACKUP_DEST:?BACKUP_DEST not set}"
 | 
			
		||||
 | 
			
		||||
if [ -n "$SERVICES_OVERRIDE" ]; then
 | 
			
		||||
	# this is fine because docker service names should never include spaces or
 | 
			
		||||
	# glob characters
 | 
			
		||||
@ -82,7 +85,7 @@ for service in "${services[@]}"; do
 | 
			
		||||
	fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
# Check if restic repo exists
 | 
			
		||||
# check if restic repo exists, initialise if not
 | 
			
		||||
if [ -z "$(_restic cat config)" ] 2>/dev/null; then
 | 
			
		||||
	echo "initializing restic repo"
 | 
			
		||||
	_restic init
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user