Creates a simple backup of your directory by copying the directory.
10K+
This image creates a simple backup of your directory by copying it.
The backup directory is placed beside the source directory and a date stamp is added. In case a backup directory already exists for the current date a counter will be added.
Assuming the current date is 25th of May in 2024 the following results can be expected:
docker run
-v /data:/app/data
steveliedtke/simple_backup_dir:0.7.1 /app/backup.sh data/my_directory
docker run
-v /data:/app/data
-e BACKUP_DIR=data/my_directory
steveliedtke/simple_backup_dir:0.7.1
You can run the backup as a Kubernetes Job. Here's an example manifest:
apiVersion: batch/v1
kind: Job
metadata:
name: directory-backup-job
spec:
template:
spec:
containers:
- name: backup
image: steveliedtke/simple_backup_dir:0.7.1
env:
- name: BACKUP_DIR
value: "data/my_directory"
volumeMounts:
- name: data-volume
mountPath: /app/data
volumes:
- name: data-volume
persistentVolumeClaim:
claimName: your-pvc-name
restartPolicy: Never
This job will:
/app/dataFor use with ArgoCD, you can modify the metadata to use generateName and hook annotations:
metadata:
generateName: directory-backup-
annotations:
argocd.argoproj.io/hook: PreSync
The backup script supports automatic cleanup of old backups through two optional environment variables. Both variables have no default values, meaning if they are not set, no cleanup will be performed:
This option allows you to keep a specific number of the most recent backups and remove older ones.
docker run
[..]
-e CLEANUP_MORE_THAN=5
steveliedtke/simple_backup_dir:0.7.1
In this example, only the 5 most recent backups will be kept. After creating a new backup, any older backups beyond this limit will be automatically removed.
This option allows you to remove backups that are older than a specified number of days.
docker run
[..]
-e CLEANUP_OLDER_THAN_DAYS=30
steveliedtke/simple_backup_dir:0.7.1
In this example, any backups that are older than 30 days will be automatically removed after creating a new backup.
You can use both cleanup options together:
docker run
[..]
-e CLEANUP_MORE_THAN=5
-e CLEANUP_OLDER_THAN_DAYS=30
steveliedtke/simple_backup_dir:0.7.1
This will ensure that:
Note that both cleanup operations run independently, so whichever condition is met first will trigger the removal of the backup.
You can display the script's help information using either -h or --help:
docker run steveliedtke/simple_backup_dir:0.7.1 /app/backup.sh --help
This will show all available arguments and environment variables with their descriptions.
This environment variable controls the type of regular expression syntax used for finding backup directories. It's particularly useful when running the container in different environments.
docker run
[..]
-e ALPINE_REGEX=false
steveliedtke/simple_backup_dir:0.7.1
ALPINE_REGEX=true: Uses Alpine Linux compatible regex syntax (default when using the docker image)ALPINE_REGEX=false: Uses standard regex syntax with Perl-compatible patternsThis setting may need to be adjusted if you're experiencing issues with backup directory detection in different environments. The Alpine version is particularly useful when running the container on Alpine-based images.
Content type
Image
Digest
sha256:ab3fbc6c5…
Size
3.9 MB
Last updated
about 2 months ago
docker pull steveliedtke/simple_backup_dir