scripts voor database management
De (larger) database packages I use - MongoDB and Postgres - come with a database server, that are configured to start up when my computer starts up. Nevertheless sometimes they may need to be stopped and (re)started in between and having commands to do backup/restore put in a script also comes in handy.
I have the following commando's:
- db.start-mongo
start mongo database server
- db.start-pg
start postgresql database server
- db.stop-mongo
stop mongo database server
- db.stop-pg
stop postgresql database server
- db.restart-mongo
restart mongo database server
- db.restart-pg
restart postgresql database server
- db.dump-mongo
dump (backup) all or selected mongo database(s) to a specific location
- db.dump-pg
dump (backup) all or selected postgres database(s) to a specific location
- db.list-mongodumps
list directories containing backups made using db.dump-mongo
- db.list-pgdumps
list backups made using db.dump-pg
- db.repair-mongo
repair mongo db
- db.restore-mongo
restore mongo database(s) from given directory (named like <EEjjmmdd-hhmmss>)
- db.restore-pg
restore postgres database(s) from given file (named like <EEjjmmdd>/<database>-<hhmmss>.sql)