Manual MongoDB Backup and Restore for the Swimlane 10.x platform
In case there are problems with the built in snapshots and there is a dire need to backup and archive the data then use this method to alternatively backup and restore the data.
Backup the data
The steps outlined below will store a backup of the data inside the Swimlane Tools container, copy the data to the running host, and optionally copy them to another host for safekeeping:
# Run the backup script. It will generate a Swimlane.tgz backup in the /dump folder of the Swimlane Tools Container:
kubectl exec swimlane-tools-0 -n default -- /bin/bash -c "nohup python3 /usr/local/bin/backup_restore_ha.py -v backup > /var/log/swimlane-backup.log 2>&1 &"
# Copy the Swimlane.tgz from the Swimlane Tools Container into the host machine
kubectl cp $(kubectl get pod -l app=swimlane-tools --no-headers | awk '{print $1}'):/dump/Swimlane.tgz /tmp/Swimlane.tgz
# Optionally copy from /tmp/Swimlane.tgz on the host machine to your external host for safekeeping
Restore the data
The steps outlined below will copy an existing backup into the Swimlane Tools container and perform a restore of the data:
# Copy the Swimlane.tgz backup into the Swimlane Tools Container
# Copy the Swimlane.tgz from the the host machine to Swimlane Tools Container
kubectl cp /tmp/Swimlane.tgz $(kubectl get pod -l app=swimlane-tools --no-headers | awk '{print $1}'):/dump/Swimlane.tgz
# Run the restore script
kubectl exec swimlane-tools-0 -n default -- /bin/bash -c "nohup python3 /usr/local/bin/backup_restore_ha.py -v restore > /var/log/swimlane-restore.log 2>&1 &"
# Then you can follow progress with
kubectl exec -n default -it swimlane-tools-0 -- tail -f /var/log/swimlane-restore.log
NOTE: The restore may take time before you start seeing progress on the screen:
kubectl exec -it swimlane-tools-0 -- /bin/bash -c "python3 /usr/local/bin/backup_restore_ha.py -v restore"
Defaulted container "swimlane-tools" out of: swimlane-tools, restore-wait (init)
/usr/local/lib/python3.9/dist-packages/pymongo/common.py:813: UserWarning: Unknown option sslverifycertificate
warnings.warn(str(exc))
2024-02-14T04:12:05.395+0000 preparing collections to restore from
2024-02-14T04:12:05.396+0000 don't know what to do with subdirectory "Swimlane", skipping...
2024-02-14T04:12:05.396+0000 don't know what to do with subdirectory "SwimlaneHistory", skipping...
2024-02-14T04:12:05.396+0000 don't know what to do with subdirectory "", skipping...
2024-02-14T04:12:05.396+0000 don't know what to do with subdirectory "admin", skipping...
<NEED TO WAIT HERE BEFORE THE PROGRESS CONTINUES>
2024-02-14T04:12:06.400+0000 restoring users from archive '/dump/Swimlane.tgz'
2