Backups when migrating DB

This commit is contained in:
kexkey
2019-03-07 12:44:03 -05:00
committed by kexkey
parent bdf303ee52
commit 11f8891eea
2 changed files with 8 additions and 2 deletions

View File

@@ -1,10 +1,13 @@
#!/bin/sh
echo "Checking for OTS support in DB..."
sqlite3 db/proxydb ".tables" | grep "stamp" > /dev/null
sqlite3 $DB_FILE ".tables" | grep "stamp" > /dev/null
if [ "$?" -eq "1" ]; then
# stamp not there, we have to migrate
echo "Migrating database for OTS support..."
echo "Backing up current DB..."
cp $DB_FILE $DB_FILE-sqlmigrate20181213_0-0.1
echo "Altering DB..."
cat sqlmigrate20181213_0-0.1.sql | sqlite3 $DB_FILE
else
echo "Database OTS support migration already done, skipping!"

View File

@@ -1,10 +1,13 @@
#!/bin/sh
echo "Checking for watch by xpub support in DB..."
sqlite3 db/proxydb ".tables" | grep "watching_by_pub32" > /dev/null
sqlite3 $DB_FILE ".tables" | grep "watching_by_pub32" > /dev/null
if [ "$?" -eq "1" ]; then
# watching_by_pub32 not there, we have to migrate
echo "Migrating database for watch by xpub support..."
echo "Backing up current DB..."
cp $DB_FILE $DB_FILE-sqlmigrate20190130_0.1-0.2
echo "Altering DB..."
cat sqlmigrate20190130_0.1-0.2.sql | sqlite3 $DB_FILE
else
echo "Database watch by xpub support migration already done, skipping!"