Skip to content

Instantly share code, notes, and snippets.

@X0nic
Last active December 14, 2015 08:28
Show Gist options
  • Save X0nic/5057566 to your computer and use it in GitHub Desktop.
Save X0nic/5057566 to your computer and use it in GitHub Desktop.
handy ssh
#!/bin/bash
# dump restore in one command
ssh -C {ssh.user}@{remote_host} mysqldump -u {remote_dbuser} --password={remote_dbpassword} \
{remote_dbname} | mysql -u {local_dbuser} --password={local_dbpassword} -D {local_dbname}
# grab a backup zip
ssh -C {ssh.user}@{remote_host} mysqldump -u {remote_dbuser} --password={remote_dbpassword} \
{remote_dbname} | gzip > {dbname}.sql.gz
# use bzip
mysqldump | bzip2 | ssh ‘cat > bunzip2 | mysql -u -p’
# compress and transfer a directory on the fly
ssh [host] "cd /var/www/;tar zcf – ." | tar zxf –
ssh [host] "tar -czf – /var/www/" > test.tgz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment