首页 > 解决方案 > Getting a database dump from a remote server without an intermediary file

问题描述

I want to write a script in python that will knock on a remote server, dump the database for me locally and automatically deploy the dump on my system.

I found an interesting script that shows how to download a dump to a local machine, but I don't like that it makes a dump on the server, downloads, and then deletes it on the server. Previously, I used SH crypts and could download the dump directly to my pc like this:

currentDate=$(date +%Y-%m-%d_%H-%M)
ssh blabla@###.###.###.### -p ### "mysqldump -v --insert-ignore --skip-lock-tables --single-transaction=TRUE -u emoteDbUser -premoteDbPass remoteDbName" > /var/www/html/PROJECTNAME$currentDate.sql

Tell me please, can I achieve the same effect through python using this script as an example?https://github.com/sakibiqbal/ssh-mysql-dump/blob/master/mysql-remote-dump.py

标签: pythonmysqlpython-3.xautodeploy

解决方案


推荐阅读