This bash script is designed to simply the process of backing up / updating Docker containers using Docker Compose.
Go to file
Robert @ Tech Addressed 0f829f3661 Update docker-maintenance.env 2023-11-05 06:09:59 +00:00
LICENSE Add LICENSE 2023-10-17 05:25:54 +00:00
README.md Update README.md 2023-11-05 04:46:11 +00:00
docker-maintenance Update docker-maintenance 2023-11-05 05:49:48 +00:00
docker-maintenance-functions Update docker-maintenance-functions 2023-11-05 06:07:40 +00:00
docker-maintenance.env Update docker-maintenance.env 2023-11-05 06:09:59 +00:00

README.md

Docker Maintenance Script

Written by: Robert Partridge (@techaddressed@fosstodon.org)

This bash script is designed to simplify managing Docker, including features like: backing up containers / updating containers / cleaning up unnecessary images.

image

FEATURES

  • Multiple Backup Methods: The script can be configured to either create a snapshot of the running container or backup only the files stored in the container's host directory.

  • Snapshot Backups: The script creates a .tar backup of each specified container including all of its associated data.

  • File Only Backups: The script creates a .tar.gz backup of each container's sub-directory and any files stored in mapped directories therein. All containers are stopped prior to backup - to prevent any potential changes to the data that might not be caught during the backup - and then restarted when the backup is complete.

  • Backup Retention - You can configure the script with the number of backups you wish to retain / removing the oldest backup should the newest backup exceed that amount.

  • Container Updates: If your containers make use of a 'latest' tag to indicate you wish to always keep the container up-to-date on the latest release, your container will be updated when after the backup is complete.

  • Configurable Variables: The script comes with the file docker-maintenance.env which contains user configurable variables for information such as file paths and backup retention settings.

  • Maintenance & Error Logs: The script creates maintenance and error logs stored in yearly sub-directories. The maintenance logs record the date & time of each maintenance operation.

  • Permissions Check: The script has the ability to check for superuser permissions. The script checks that it's been executed with these permissions and will exit with an error message if you have not. This error does not get recorded to the log as the script won't have appropriate permissions to do so. The permission check is required if your user account isn't a member of the Docker group, your backup location or log files require such permissions, or if you have any containers that have file permissions that would require it. This check can be disabled via a user configurable variable.

  • Disk Space Check: If you attempt to run this script and there isn't sufficient disk space to store the container backups that would be generated in the specified location, the script will exit with an error message and record this error to the error log.

  • Container Image Clean-Up: The script checks for any unnecessary outdated container images and removes them to free up disk space.

LIMITATIONS

At this time, the script is designed / tested to ONLY update containers created from publicly available images. Backing up containers created from non-public images should work perfectly fine, however, updating containers that aren't created from publicly available images is not likely to work.

HOW TO USE THIS SCRIPT

If you require detailed instructions / examples on how to use this script, please refer to my comprehensive tutorial - COMING SOON - that covers everything you need to know including setup, configuration, and common use cases.

SOFTWARE SUPPORT

This is unsupported software - use it at your own discretion.

LICENSE

This project is released under the MIT License

CONTACT

If you have questions or feedback, you can find me on Mastodon.