* Make the backup puller a full-fledged script after all. * Finish the main portion. * Remove version tag to avoid log errors on Docker 26.0, Compose 2.25.0. * Try moving to a smaller, faster, more stable image. * Move Nextcloud to the stable tag. * Add shortcut aliases. * Rename container website to www. * Do not install the latest of the PHP or Node programs if a version already exists in the container. * We need git!! * Try only git and the PHP interpretor. * Remove comments. * Install express at the image layer, not during runtime. * Let the app install express after all. * Remove warning about apt CLI. * Try to cache the express download/install. * Fix caching of Node packages.
		
			
				
	
	
		
			76 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			76 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env bash
 | |
| # 2024-01-29 Hyperling
 | |
| # Example of how to pull the polled Backip.zip file. This would be placed on
 | |
| # the machine holding the backups in the directory that it should land.
 | |
| 
 | |
| DIR="$(dirname -- "${BASH_SOURCE[0]}")"
 | |
| PROG="$(basename -- "${BASH_SOURCE[0]}")"
 | |
| echo "$DIR/$PROG"
 | |
| 
 | |
| ## Variables ##
 | |
| 
 | |
| DATE="`date '+%Y%m%d'`"
 | |
| NEWFILE="$DIR/Backup_${DATE}.zip"
 | |
| PREVIOUS="`ls $DIR/Backup_*.zip | sort -r | head -n 1`"
 | |
| 
 | |
| ## Functions ##
 | |
| 
 | |
| function usage {
 | |
| 	echo -e "Usage: $PROG -d DESTINATION [-u USER] [-p PORT] [-h]\n"
 | |
| 	cat <<- EOF
 | |
| 		Download the latest Backup.zip from a Hyperling/Docker type project. The
 | |
| 		file is downloaded to the directory that this file exists in, so that it
 | |
| 		can be conveniently kept with the backups themselves.
 | |
| 
 | |
| 		Parameters
 | |
| 		  -d : The server name or IP address running hhe Docker instance.
 | |
| 		  -u : Username to connect as. Default LOGNAME, currently '$LOGNAME'.
 | |
| 		  -p : Port to connect through. Defaults to 22.
 | |
| 		  -h : Display this usage text.
 | |
| 	EOF
 | |
| }
 | |
| 
 | |
| ## Parameters ##
 | |
| 
 | |
| port=22
 | |
| user="$LOGNAME"
 | |
| while getopts ':d:u:p:h' opt; do
 | |
| 	case "$opt" in
 | |
| 		d) destination="$OPTARG" ;;
 | |
| 		u) user="$OPTARG" ;;
 | |
| 		p) port="$OPTARG" ;;
 | |
| 		h) usage 0 ;;
 | |
| 		*) echo "ERROR: Parameter '$OPTARG' not recognized." >&2
 | |
| 			usage 1 ;;
 | |
| 	esac
 | |
| done
 | |
| 
 | |
| ## Validations ##
 | |
| 
 | |
| if [[ -z $destination ]]; then
 | |
| 	echo "ERROR: Destination was not provided." >&2
 | |
| 	usage 2
 | |
| fi
 | |
| 
 | |
| ## Main ##
 | |
| 
 | |
| echo "`date` - Creating '$NEWFILE'."
 | |
| scp -P $port "$user@[$destination]":/tmp/Backup.zip $NEWFILE.tmp
 | |
| mv -v $NEWFILE.tmp $NEWFILE
 | |
| 
 | |
| ## Validation ##
 | |
| 
 | |
| # TBD: Can make this fancier, such as doing a real comparison for size growth.
 | |
| 
 | |
| echo "`date` - New backup's size:"
 | |
| du -h $NEWFILE
 | |
| 
 | |
| if [[ -n $PREVIOUS ]]; then
 | |
| 	echo "`date` - Previous backup's size:"
 | |
| 	du -h $PREVIOUS
 | |
| fi
 | |
| 
 | |
| ## Finish ##
 | |
| 
 | |
| exit 0
 |