Question

On my CentOS VPS server I currently backup all my hosted website files via an automated SFTP session using a script. I use WinSCP for this. Unfortunately, this does not include a backup of the MySQL databases which I have about 20 of.

Is it best to run a scheduled dump of the databases into a folder and then ftp this over, or can I use WinSCP to dump them, individually, on-the-fly into a folder during a session? I would prefer the latter option.

If so, how do I achieve this?

I want to end up with a working backup of my databases, on my local Windows PC, that can be reinstated if required.

Thanks in advance

Was it helpful?

Solution

You can use the WinSCP command call to run the mysqldump, before you start the download (i.e. before the get or synchronize command).

For examples see:
https://winscp.net/eng/docs/scriptcommand_call

You may need to increase a session timeout (15s default) to allow the call to finish in time.


Alternatively you can run the mysqldump using a more appropriate tool, like plink (from PuTTY suite), before you start WinSCP script:
https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter7.html

OTHER TIPS

scp (and its windows client variant you're using, WinSCP) are best for file copying. You could use ssh to run a command to dump each of your databases and then copy them.

But you are probably better off setting up a scheduled dump of each database that operates locally to the CentOS server.

If you happen to be using one of the well-known content management systems for your website (like WordPress, etc) you should investigate the various excellent and free (free as in speech, free as in beer) backup plugins available for those systems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top