2
0

🛂 Add backup and restore database scripts

This commit is contained in:
Baptiste Arnaud
2022-11-23 11:40:57 +01:00
parent d80cc1b248
commit 3645607ed4
10 changed files with 107 additions and 43 deletions

View File

@@ -0,0 +1,23 @@
import { exec } from 'child_process'
import { promptAndSetEnvironment } from './utils'
const restoreDatabase = async () => {
await promptAndSetEnvironment()
exec(
`pg_restore -d ${process.env.DATABASE_URL} -c dump.tar`,
(error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`)
return
}
if (stderr) {
console.log(`stderr: ${stderr}`)
return
}
console.log(`stdout: ${stdout}`)
}
)
}
restoreDatabase()