From 34d3334a644943c31c3aef809cf87286e5e4165f Mon Sep 17 00:00:00 2001 From: Allan Zimmermann Date: Tue, 19 Jul 2022 06:46:43 +0200 Subject: [PATCH] add backup/restore script --- db-backup.sh | 7 +++++++ db-restore.sh | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 db-backup.sh create mode 100644 db-restore.sh diff --git a/db-backup.sh b/db-backup.sh new file mode 100644 index 0000000..3a95b05 --- /dev/null +++ b/db-backup.sh @@ -0,0 +1,7 @@ +#!/bin/sh +docker-compose exec mongodb rm /tmp/openflow.bak +docker-compose exec mongodb /usr/bin/mongodump --db openflow --gzip --archive=/tmp/openflow.bak +docker compose cp mongodb:/tmp/openflow.bak . +current_time=$(date "+%Y.%m.%d-%H.%M.%S") +echo "Current Time : $current_time" +cp openflow.bak openflow.$current_time.bak diff --git a/db-restore.sh b/db-restore.sh new file mode 100644 index 0000000..ce43897 --- /dev/null +++ b/db-restore.sh @@ -0,0 +1,3 @@ +#!/bin/sh +docker compose cp openflow.bak mongodb:/tmp/ +docker-compose exec mongodb /usr/bin/mongorestore --gzip --archive=/tmp/openflow.bak