Skip to content

Instantly share code, notes, and snippets.

@ninodafonte
Last active April 20, 2018 10:34
Show Gist options
  • Save ninodafonte/967cd25f17a5c0a71f32541141a6d444 to your computer and use it in GitHub Desktop.
Save ninodafonte/967cd25f17a5c0a71f32541141a6d444 to your computer and use it in GitHub Desktop.
Restore dump python
https://stackoverflow.com/questions/12124959/import-sql-dump-with-subprocess
with open(dump_filename, 'r') as f:
command = ['mysql', '-u%s' % db_settings['USER'], '-p%s' % db_settings['PASSWORD'], db_settings['NAME']]
proc = subprocess.Popen(command, stdin = f)
stdout, stderr = proc.communicate()
Also check https://codepoets.co.uk/2010/python-script-to-backup-mysql-databases-on-debian/ for dumps
Download the dump from S3 example:
http://boto3.readthedocs.io/en/latest/guide/s3-example-download-file.html
Use aws cli inside docker:
docker run -it --rm -e AWS_DEFAULT_REGION='[your region] -e AWS_ACCESS_KEY_ID='[your access ID] -e AWS_SECRET_ACCESS_KEY='[your access key] image:version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment