diff options
author | tomamplius <thomas@lgy.fr> | 2019-07-02 19:05:23 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-07-02 19:05:23 +0200 |
commit | e6fdfdc29277b23c68b5df06e1f6e5b374313862 (patch) | |
tree | d2d75957e1ac8f37d5f5181434c7abd0a10b8e1e | |
parent | bfc6bb947d5e464c6038763baf7bf99388aa87f7 (diff) | |
download | PeerTube-e6fdfdc29277b23c68b5df06e1f6e5b374313862.tar.gz PeerTube-e6fdfdc29277b23c68b5df06e1f6e5b374313862.tar.zst PeerTube-e6fdfdc29277b23c68b5df06e1f6e5b374313862.zip |
Check pg_dump before backup (#1950)
* Check pg_dump before backup
When the database is not on the same host pg_dump can't be not present
* Update upgrade.sh
-rwxr-xr-x | scripts/upgrade.sh | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh index 5d7c5b0ea..425d19c06 100755 --- a/scripts/upgrade.sh +++ b/scripts/upgrade.sh | |||
@@ -32,14 +32,18 @@ if [ -x "$(command -v awk)" ] && [ -x "$(command -v sed)" ] ; then | |||
32 | fi | 32 | fi |
33 | 33 | ||
34 | # Backup database | 34 | # Backup database |
35 | SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak" | 35 | if [ -x "$(command -v pg_dump)" ] |
36 | DB_USER=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['username'])") | 36 | then |
37 | DB_PASS=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['password'])") | 37 | SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak" |
38 | DB_HOST=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['hostname'])") | 38 | DB_USER=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['username'])") |
39 | DB_SUFFIX=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['suffix'])") | 39 | DB_PASS=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['password'])") |
40 | mkdir -p $PEERTUBE_PATH/backup | 40 | DB_HOST=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['hostname'])") |
41 | 41 | DB_SUFFIX=$(node -e "console.log(require('js-yaml').safeLoad(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['suffix'])") | |
42 | PGPASSWORD=$DB_PASS pg_dump -U $DB_USER -h $DB_HOST -F c "peertube${DB_SUFFIX}" -f "$SQL_BACKUP_PATH" | 42 | mkdir -p $PEERTUBE_PATH/backup |
43 | PGPASSWORD=$DB_PASS pg_dump -U $DB_USER -h $DB_HOST -F c "peertube${DB_SUFFIX}" -f "$SQL_BACKUP_PATH" | ||
44 | else | ||
45 | echo "pg_dump not found. Cannot make a SQL backup!" | ||
46 | fi | ||
43 | 47 | ||
44 | # If there is a pre-release, give the user a choice which one to install. | 48 | # If there is a pre-release, give the user a choice which one to install. |
45 | RELEASE_VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) | 49 | RELEASE_VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) |