aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/upgrade.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/upgrade.sh')
-rwxr-xr-xscripts/upgrade.sh17
1 files changed, 16 insertions, 1 deletions
diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh
index b29615fb1..4f7c58edd 100755
--- a/scripts/upgrade.sh
+++ b/scripts/upgrade.sh
@@ -20,11 +20,26 @@ if [ ! -e "$PEERTUBE_PATH/versions" -o ! -e "$PEERTUBE_PATH/config/production.ya
20 exit 1 20 exit 1
21fi 21fi
22 22
23if [ -x "$(command -v awk)" ] && [ -x "$(command -v sed)" ] ; then
24 REMAINING=$(df -k $PEERTUBE_PATH | awk '{ print $4}' | sed -n 2p)
25 ONE_GB=$((1024 * 1024))
26 if [ "$REMAINING" -lt "$ONE_GB" ]; then
27 echo "Error - not enough free space for upgrading"
28 echo ""
29 echo "Make sure you have at least 1 GB of free space in $PEERTUBE_PATH"
30 exit 1
31 fi
32fi
23 33
24# Backup database 34# Backup database
25SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak" 35SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak"
36DB_USER=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['username'])")
37DB_PASS=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['password'])")
38DB_HOST=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['hostname'])")
39DB_SUFFIX=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['suffix'])")
26mkdir -p $PEERTUBE_PATH/backup 40mkdir -p $PEERTUBE_PATH/backup
27pg_dump -U peertube -W -h localhost -F c peertube_prod -f "$SQL_BACKUP_PATH" 41
42PGPASSWORD=$DB_PASS pg_dump -U $DB_USER -h $DB_HOST -F c "peertube${DB_SUFFIX}" -f "$SQL_BACKUP_PATH"
28 43
29# If there is a pre-release, give the user a choice which one to install. 44# If there is a pre-release, give the user a choice which one to install.
30RELEASE_VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) 45RELEASE_VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4)