Those are primary utilities to collect backups and send it to remote location over secure channel.
This is regular container packed all utilities together. Run container and mount directory that you want to backup. Use every utility the way you would use it regular way.
If you know your timezone for example America/New_York then immediately after container run cp /usr/share/zoneinfo/America/New_York /etc/localtime otherwise check allavailable options inside the container by using ls /usr/share/zoneinfo/
Copying directory from docker host to remote server over SSH:
docker run --rm -i \
-v <ssh identity>:/ssh-identity/id_rsa \
-v <local-dest-path>:/storage \
ikuchin/ssh-rsync-mysql-client \
rsync -rptoDzh --delete -e \"ssh -i /ssh-identity/id_rsa -o 'StrictHostKeyChecking no'\" /storage/ <ssh user>@<IP>:/storage
Same as above done only on Fri with in NY timezone:
docker run --rm -i \
-v <ssh identity>:/ssh-identity/id_rsa \
-v <local-dest-path>:/storage \
ikuchin/ssh-rsync-mysql-client \
cp /usr/share/zoneinfo/America/New_York /etc/localtime \
if [[ $(date +%u) -eq 5 ]]; then \
rsync -rptoDzh --delete -e \"ssh -i /ssh-identity/id_rsa -o 'StrictHostKeyChecking no'\" /storage/ <ssh user>@<IP>:/storage; \
'fi`
apiVersion: batch/v1
kind: CronJob
metadata:
name: backup-daily-cronjob
spec:
schedule: "0 3 * * *"
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
securityContext:
runAsUser: 0
runAsGroup: 33
volumes:
- name: images-vol
persistentVolumeClaim:
claimName: images-pvc
- name: ssh-identity-vol
configMap:
name: ssh-identity-secret
defaultMode: 0400
containers:
- name: backup-container
image: ikuchin/ssh-rsync-mysql-client
env:
- name: TZ
value: Europe/Moscow
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- name: images-vol
mountPath: /storage_local/images
readOnly: true
- name: ssh-identity-vol
mountPath: /ssh-identity
command: ["/bin/sh", "-c"]
args: ["cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime \
&& rsync -rptoDzh --delete -e \"ssh -i /ssh-identity/id_rsa -o 'StrictHostKeyChecking no'\" /storage_local/images/ <ssh user>@<IP>:/storage/ikuchin/backup/${NAMESPACE}/rsync/ \
&& mysqldump --add-drop-table -Q -h db-service -u backup -pbackup www | gzip > mysql_dump_`date +%Y%m%d%H%M%S`.gz \
&& tar -czf images_`date +%Y%m%d%H%M%S`.tar.gz /storage_local/images/ \
&& scp -i /ssh-identity/id_rsa -o 'StrictHostKeyChecking no' mysql_*.gz <ssh user>@<IP>:/storage/ikuchin/backup/${NAMESPACE}/mysql/ \
&& scp -i /ssh-identity/id_rsa -o 'StrictHostKeyChecking no' images_*.gz <ssh user>@<IP>:/storage/ikuchin/backup/${NAMESPACE}/images/ \
&& scp -i /ssh-identity/id_rsa -o 'StrictHostKeyChecking no' mysql_*.gz <ssh user>@<IP>:/storage/ikuchin/backup/${NAMESPACE}/mysql/ \
&& if [[ $(date +%u) -eq 5 ]]; then scp -i /ssh-identity/id_rsa -o 'StrictHostKeyChecking no' images_*.gz <ssh user>@<IP>:/storage/ikuchin/backup/${NAMESPACE}/images/; fi"]
resources:
limits:
cpu: 250m
requests:
cpu: 100m
restartPolicy: Never
Content type
Image
Digest
Size
16.6 MB
Last updated
almost 5 years ago
docker pull ikuchin/ssh-rsync-mysql-client