Skip to content

Commit

Permalink
chore: Only export appsmith schema to avoid backing up un-necessary s…
Browse files Browse the repository at this point in the history
…chemas
  • Loading branch information
abhvsn committed Nov 13, 2024
1 parent 7933a05 commit a6d9be8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deploy/docker/fs/opt/appsmith/utils/bin/backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async function executeMongoDumpCMD(destFolder, dbUrl) {
}

async function executePostgresDumpCMD(destFolder, dbUrl) {
return await utils.execCommand(['pg_dump', dbUrl, '-Fc', '-f', destFolder + '/pg-data.archive']);
return await utils.execCommand(['pg_dump', dbUrl, '--verbose', '-n', 'appsmith','-Fc', '-f', destFolder + '/pg-data.archive']);
}

async function createFinalArchive(destFolder, timestamp) {
Expand Down
5 changes: 3 additions & 2 deletions deploy/docker/fs/opt/appsmith/utils/bin/export_db.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Init function export mongodb
// Init function export db
const shell = require('shelljs');
const Constants = require('./constants');
const utils = require('./utils');
Expand All @@ -11,7 +11,8 @@ function export_database() {
if (dbUrl.startsWith('mongodb')) {
cmd = `mongodump --uri='${dbUrl}' --archive='${Constants.BACKUP_PATH}/${Constants.DUMP_FILE_NAME}' --gzip`;
} else if (dbUrl.startsWith('postgresql')) {
cmd = `pg_dump ${dbUrl} -Fc -f '${Constants.BACKUP_PATH}/${Constants.DUMP_FILE_NAME}'`;
// Dump only the appsmith schema with custom format
cmd = `pg_dump ${dbUrl} --verbose -n appsmith -Fc -f '${Constants.BACKUP_PATH}/${Constants.DUMP_FILE_NAME}'`;
} else {
throw new Error('Unsupported database URL');
}
Expand Down
2 changes: 1 addition & 1 deletion deploy/docker/fs/opt/appsmith/utils/bin/import_db.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function get_table_or_collection_len() {
if (utils.getDburl().startsWith('mongodb')) {
count = shell.exec(`mongo ${utils.getDburl()} --quiet --eval "db.getCollectionNames().length"`)
} else if (utils.getDburl().startsWith('postgresql')) {
count = shell.exec(`psql -U postgres -d ${utils.getDburl()} -t -c "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'appsmith';"`)
count = shell.exec(`psql -d ${utils.getDburl()} -t -c "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'appsmith';"`)
}
return parseInt(count.stdout.toString().trimEnd());
}
Expand Down

0 comments on commit a6d9be8

Please sign in to comment.