Copybase is a database tool that helps you quickly copy a database. Simply define your databases config in a .copybaserc.yaml
, and start copying or backuping them with a simple command line:
copybase copy staging local
copybase backup prod
Note: copybase uses the native tools to build command lines to launch. So you still need to install mysql, psql or mongo.
# install copybase globally
npm i -g copybase
# with yarn:
yarn global add copybase
# or locally
npm i copybase
# with yarn:
yarn add copybase
You also need to install the official db tools:
Copybase uses cosmiconfig, so you just need to create a file .copybaserc.yaml
(or .copybaserc.json
, .copybaserc.js
) with the following sample config:
backup:
# output folder when you run the backup command
folder: .backup
# list all databases you want to work with
databases:
# sample config for localhost
local:
database: demo
protocol: postgresql
hostname: 127.0.0.1
port: 54321
username: demo
password: password
# sample config for a remote database, uring uri
staging:
uri: postgresql://demo:staging.example.com@localhost:54322/demo
Note: you can pass some extra parameters to the command line underneath. Look at .copybaserc.yaml in the current repository.
Usage: copybase [options] [command]
Copy quickly a database
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
copy [options] <fromDatabase> <toDatabase> Copy a database
list:tables [options] <database> List all tables in database
backup [options] <database> Backup a database
restore [options] <from> <toDatabase> Restore a database
help [command] display help for command