Comments (1)
It should completely stop working with intermediate remote files at all. You can run ssh -L127.33.0.6:3306:$DBHOST:$DBPORT
and connect mysqldump to the localhost instead: mysqldump ... -h 127.33.0.6
. This would also eliminate the need for transferring the DB password over the wire and being logged plain text. I'm not sure if sshkit allows setting up port forwards, tho.
Storing a compressed local copy may still be beneficial but everything could be forged into one single step:
mysqldump --compress -h 127.33.0.6 -u remoteuser -p remotepw ... |\
tee localcopy.sql |\
mysqldump -h 127.0.0.1 -u localuser -p localpw ...
or if compressed local storage is needed (bash only):
mysqldump --compress -h 127.33.0.6 -u remoteuser -p remotepw ... |\
tee >(bzip2 >localcopy.sql.bz2) |\
mysqldump -h 127.0.0.1 -u localuser -p localpw ...
or with unobstrusive progress meter (bash only):
mysqldump --compress -h 127.33.0.6 -u remoteuser -p remotepw ... |\
tee >(bzip2 >localcopy.sql.bz2) >(pv -br) |\
mysqldump -h 127.0.0.1 -u localuser -p localpw ...
In these examples, the port forwarding to the remote side lives on 127.33.0.6. This was chosen to not collide with the local mysql server probably already listening von 127.0.0.1 (as in this example). Some important parameters have been omitted (e.g., database name). Both examples pretend that you've setup the tunnel before:
ssh -L127.33.0.6:3306:dbserver:3306
There's nothing to type in the SSH shell, thus no command line is transferred. After mysqldump is done, just exit the SSH session. If mysqldump is still connected, SSH won't exit just yet. The remote infrastructure would see database connects coming from the SSH server, not your client.
I never used Postgres but it should work in a very similar way.
from capistrano-db-tasks.
Related Issues (20)
- undefined method `zone' for Time:Class HOT 2
- NoMethodError: undefined method `zone' for Time:Class HOT 2
- SSHKit::Runner::ExecuteError "rails exit status: 127" in versions 0.5 and 0.6 HOT 11
- Net::SCP failure when db_dump_dir is set HOT 2
- NoMethodError: undefined method `[]' for nil:NilClass HOT 1
- DB:pull 127 error HOT 10
- how do I pass credentials to pg_dump?
- Option to drop database before import HOT 2
- Note in Docs for use with capistrano-rvm
- istrano HOT 2
- cap staging db:pull causes this problem :( HOT 2
- Serial id lost after db push HOT 2
- scp should happen before remote clean HOT 1
- Doesn't work on winows 10 sub-systems (/usr/bin/env: ‘ruby.exe’: No such file or directory)
- Strip adapter check? HOT 2
- Can not accept `db_dump_dir` configuration HOT 1
- Append the `db:download` task
- Multi database support is broken
- Question to users HOT 2
- `db_ignore_data_tables` setting doesn't work on MySQL
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from capistrano-db-tasks.