Major Enhancements (#20)

* Fix program for html websites, need to handle errors for non-local sites though.

* Add message that the main program is starting since node-modules does not show anything.

* Go ahead and give DB a bump.

* Fix warning in DB log and NC not having enough power sometimes.

* Fix errors in DB log.

* This command uses the root account, not nextcloud.

* Add example CRON file.

* Specify that the host network should be used.

* Specify that the host network should be used.

* Recommend daily reset of the photos library.

* Add another package the container is missing.

* Add a backup script for the project directory.

* Fix a typo.

* Improve example file and add the backup job.

* Add an example of pulling the backup file.

* Give the zip a temporary filename while being built.

* Always get the full path, relative path does not work well when not in `.`.

* Remove extra newline.

* Prevent doing large uploads on a micro Nextcloud instance.

* Change how bz2 gets installed.

* More trying to fix the annoying bz2 warning.

* Remove "bad" package.

* Use a temporary filename during transfer.

* Bump CPUs up just a bit more for Nextcloud to avoid sync errors.

* Be more explicit with instructions.
This commit is contained in:
2024-01-30 06:11:32 -07:00
committed by GitHub
parent cf0d028a58
commit 1ef1903f6b
14 changed files with 146 additions and 22 deletions

43
bin/backup.sh Executable file
View File

@ -0,0 +1,43 @@
#!/usr/bin/env bash
# 2024-01-29 Hyperling
# Create a backup file with a generic name for polling.
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
PROG="$(basename -- "${BASH_SOURCE[0]}")"
echo "$DIR/$PROG"
source $DIR/../source.env
## Variables ##
file="/tmp/Backup.zip"
time="`which time`"
## Main ##
# Remove the last backup.
if [[ -e $file ]]; then
echo "`date` - Removing existing file."
rm -fv $file
fi
echo -e "\n`date` - Take down services for a cold backup."
manage.sh -d
echo -e "\n`date` - Create the backup for '$DOCKER_HOME'."
cd $DOCKER_HOME
$time zip -r $file.tmp . 1>/dev/null
mv -v $file.tmp $file
echo -e "\n`date` - Done with zipping, check size."
ls -sh $file
echo -e "\n`date` - Ensure other users can access the file."
chmod -v 755 $file
echo -e "\n`date` - Bring services back up."
manage.sh -u
## Finish ##
echo -e "\n`date` - Done!"
exit 0

View File

@ -70,7 +70,7 @@ function check_container() {
# Ensure a container which will be accessed is either running or starting.
# Parameters:
# 1) CONTAINER, either as ID or Name.
# 2) WHy the container is being checked.
# 2) Why the container is being checked.
container_to_check="$1"
reason_to_check="$2"
@ -111,9 +111,9 @@ fi
# Script will behave poorly if not run with admin privileges.
if [[ $LOGNAME != "root" ]]; then
echo "*************************************************************"
echo "WARNING: Script is intended for root. Please su or sudo/doas."
echo -e "*************************************************************\n"
echo "*************************************************************"
echo "WARNING: Script is intended for root. Please su or sudo/doas."
echo "*************************************************************"
fi
# Options which only work if the container exists or is going to be started.

34
bin/pull_backup.example.sh Executable file
View File

@ -0,0 +1,34 @@
#!/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"
LATEST="`ls $DIR/Backup_*.zip | sort -r | head -n 1`"
## Main ##
echo "`date` - Creating '$NEWFILE'."
scp -P 4022 user@example.com:/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
echo "`date` - Previous backup's size:"
du -h $LATEST
## Finish ##
exit 0