-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Introduce backup and restore for postgres
- Loading branch information
Showing
6 changed files
with
90 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,16 @@ test('Test mongodump CMD generaton', async () => { | |
console.log(res) | ||
}) | ||
|
||
test('Test postgresdump CMD generaton', async () => { | ||
var dest = '/dest' | ||
var appsmithMongoURI = 'postgresql://username:password@host/appsmith' | ||
var cmd = 'pg_dump postgresql://username:password@host/appsmith -Fc -f /dest/pg-data.archive' | ||
utils.execCommand = jest.fn().mockImplementation(async (a) => a.join(' ')); | ||
const res = await backup.executePostgresDumpCMD(dest, appsmithMongoURI) | ||
expect(res).toBe(cmd) | ||
console.log(res) | ||
}) | ||
|
||
test('Test get gitRoot path when APPSMITH_GIT_ROOT is \'\' ', () => { | ||
expect(backup.getGitRoot('')).toBe('/appsmith-stacks/git-storage') | ||
}); | ||
|
@@ -229,28 +239,28 @@ test('Test backup encryption function', async () => { | |
test('Get DB name from Mongo URI 1', async () => { | ||
var mongodb_uri = "mongodb+srv://admin:[email protected]/my_db_name?retryWrites=true&minPoolSize=1&maxPoolSize=10&maxIdleTimeMS=900000&authSource=admin" | ||
var expectedDBName = 'my_db_name' | ||
const dbName = utils.getDatabaseNameFromMongoURI(mongodb_uri) | ||
const dbName = utils.getDatabaseNameFromDBURI(mongodb_uri) | ||
expect(dbName).toEqual(expectedDBName) | ||
}) | ||
|
||
test('Get DB name from Mongo URI 2', async () => { | ||
var mongodb_uri = "mongodb+srv://admin:[email protected]/test123?retryWrites=true&minPoolSize=1&maxPoolSize=10&maxIdleTimeMS=900000&authSource=admin" | ||
var expectedDBName = 'test123' | ||
const dbName = utils.getDatabaseNameFromMongoURI(mongodb_uri) | ||
const dbName = utils.getDatabaseNameFromDBURI(mongodb_uri) | ||
expect(dbName).toEqual(expectedDBName) | ||
}) | ||
|
||
test('Get DB name from Mongo URI 3', async () => { | ||
var mongodb_uri = "mongodb+srv://admin:[email protected]/test123" | ||
var expectedDBName = 'test123' | ||
const dbName = utils.getDatabaseNameFromMongoURI(mongodb_uri) | ||
const dbName = utils.getDatabaseNameFromDBURI(mongodb_uri) | ||
expect(dbName).toEqual(expectedDBName) | ||
}) | ||
|
||
test('Get DB name from Mongo URI 4', async () => { | ||
var mongodb_uri = "mongodb://appsmith:pAssW0rd!@localhost:27017/appsmith" | ||
var expectedDBName = 'appsmith' | ||
const dbName = utils.getDatabaseNameFromMongoURI(mongodb_uri) | ||
const dbName = utils.getDatabaseNameFromDBURI(mongodb_uri) | ||
expect(dbName).toEqual(expectedDBName) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters