-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathbackup.sh
More file actions
executable file
·36 lines (30 loc) · 990 Bytes
/
backup.sh
File metadata and controls
executable file
·36 lines (30 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
DIR=$1
CMD=$2
PAGE_START=${3:-0}
BACKUP=./backup/target/release/backup
if [ ! -f $BACKUP ]; then
cd backup
cargo build --bin backup --release
cd ..
fi
set -e
mkdir -p $DIR
if [ "$CMD" == "restore" ]; then
echo "Running restore from $DIR..."
WEBSERVER_PORT=$(dfx info webserver-port)
DFX_URL="http://localhost:${WEBSERVER_PORT}" $BACKUP $DIR restore $(cat .dfx/local/canister_ids.json | jq -r ".taggr.local") $PAGE_START
echo "Clearing buckets before restoring heap..."
dfx canister call taggr clear_buckets '("")' || 1
echo "Restoring heap..."
dfx canister call taggr stable_to_heap
echo "Clearing buckets after restoring heap..."
dfx canister call taggr clear_buckets '("")'
else
echo "Running backup to $DIR..."
git rev-parse HEAD > $DIR/commit.txt
if [ "$PAGE_START" -eq 0 ]; then
dfx canister --network ic call taggr backup
fi
$BACKUP $DIR backup "6qfxa-ryaaa-aaaai-qbhsq-cai" $PAGE_START
fi