MySQLdump to directory with WinSCP or similar - mysql

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

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

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.

Related

Development environment Sinatra & MySQL in 2 computers

I'm developing a Sinatra and MySQL application. I'm using as development environment a Macbook Air and an iMac. The server runs on a FreeBSD VPS running unicorn behind nginx.
I'd like to somehow automate the whole procedure, I develop in both iMac and MBA. Depends on time I have free in the office (MBA) or time I spend writing code at home (iMac). I have setup MySQL on both macs.
I manually dump and restore the database in order to be able to test my application locally before making any change to the server.
I'd like to automate the process of: Syncing the MySQL database if possible, keep the code up-to-date to all locations without using cloud storage if possible.
Best Regards,
I think there are many ways to solve this problem.
So this is just on idea how to achieve this.
Create a git repo on your server and write a small shell script which sync your db from somewhere. This script can you trigger by a git hook http://git-scm.com/book/en/Customizing-Git-Git-Hooks#Client-Side-Hooks
For your syncing script you may have a look at this -> https://github.com/xssnark/mysql-db-sync or I'm sure you find something.

Can I run (XAMPP) MySQl inside my DropBox folder?

Lots of conflicting reports out there when I google; can anyone help?
Basically I want to have the same databases available at work & home PCs, for development porpoises only.
I will only ever be physically at one PC (with a 45 minute trip between) and only then will there be database access. The MySql service will be running on both, but only one will be write/reading the database. Both run Windows 7
I don't need to bother with symlinks, junctions, etc as I have enough space in my DropBox to install all of Xampp there.
Can I do that without corruption?
I use something similar as part of my remote development testing, I have never tried to run a large set of data from this or a production database. Haha, but for testing queries and setting up a couple rows, etc... I use something very similar with little to no problems.
I believe that you can run the portable xampp and mysql from your Dropbox just go to www.portableapps.com to get the xampp and also download the portable launcher from the link on the page.
Let XAMPP server run on your computers, and the data folder saved on your cloud (DropBox, SkyDrive, etc).
You should install XAMPP portable on your root folder (c:) that is the same on all computer you use, then you can move XAMPP data folder (xampp Apache htdocs) and MySQL data (xampp Mysql/data) folder to Dropbox.
Do not use XAMPP installer, but use the portable one.
Configure the folder settings on both Apache and MySQL config file:
C:\xampp\apache\conf\httpd.conf
C:\xampp\apache\conf\extra\httpd-ssl.conf
C:\xampp\apache\conf\extra\httpd-xampp.conf
C:\xampp\mysql\bin\my.ini
Do the same with other server that you use (PostgreSQL, etc).
Make sure that you:
Always turn off XAMPP server after using on each PC.
Always sync Dropbox before changing PC, that is before logging on and after logging off on different computer.
Mind host / local domain variable on each computer.
Its probably better to use same username for all computer you want to use to run the data folder.
Other method is using PortableAppas.com, that is running the apps directly from USB.

Many binary files synchronization

I have about 100 000 files on office server (images, pdf's, etc...)
Each day files count grows about 100-500 items, and about 20-50 old files changes.
What is the best way to synchronize Web-server with these files?
Can any system like Mercurial, GIT help?
(On office server, I'll commit changes, and web-server periodically do updates)?
Second problem is, that on Web-server I have user-generated-content (binary-files) (other files).
Each day this users upload about 1000-2000 new files. Old files don't change.
And I need to backup these files to local machine.
Can any system like Merurial, GIT help in this situation?
(On web-server I'll commit these files by cron, and on local machine I'll do updates)
Thanks
UPD.
Office server is Windows Server 2008 R2
Web-server is Debian 5 lenny
The simplest and most reliable mechanism (in my experience) is rsync.
On Windows, however, rsync over ssh is badly broken due to issues with how Cygwin interacts with named pipes. Rsync over its own protocol works (as long as you don't care about encryption), but I've had lots of problems getting rsync to stay up as a Windows service for more than a few days at a time. DeltaCopy is a Windows app that uses the rsync tools behind the scenes; it seems to work very well, though I haven't tried the ssh option.
A DVCS is not a good solution in this case: it will keep the all history, which you don't always need, and will make any clone a massive operation.
An artifact repository like Nexus is much more adapted if you need some kind of versioning with integrity check associated with your binaries.
Otherwise (no versioning), a simple rsync like Marcelo proposes is enough.

Package Java web app along with jboss, mysql and activemq for deployment

I have a springframework web application that uses JBoss, MySQL and ActiveMQ.
At the moment, I have to install and configure JBoss, MySQL and ActiveMQ and JBoss manually.
What is the best way to package the application so a user can maybe do a one click install (on Linux platform, maybe Windows too?)
The "proper" way to do it is to pull down the source or src.rpms (or the equivalent of src.rpms depending on your distro) and repackage them correctly. If you have never messed with packaging linux application then this will probably take you a long time and will yield mediocre results unless you are willing to invest a lot of time.
An easier method is to write a shell script. Copy every shell command you type into a .sh file and run that file as a privileged user. If you edit files manually (with vim, emacs or gedit) instead edit the files with perl, sed, and awk, or just crush the files by curl'ing the modified version from a local webserver or copied from scp.
You can include the commands to install the packages as well as configure them in the script if you like.
As far as ActiveMQ is in question, you can always embed it in your application. Take a look at http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html for more info

Local use of MySQL database

Is it possible to use MySQL local? I mean NOT at a server. I read a lot about MySQL on a webserver with PHP, Joomla etc.
I want to program a piece of software and use a database local to store results. Can I use MySQL for that?
If so, is ther anyware on the net a good tutorial how to do that?
You can install MySQL on your workstation, it doesn't need to be on a "server" per se. You still need to use something that can connect to it. From a Java application, for instance, you'd use JDBC; from .Net, you'd probably use ADO.Net; etc.
As far as I know, it will still want to have its server process (mysqld) running and for you to connect to that process via sockets and the like; there's no standard in-process version that I'm aware of. (The server can be listening only on the local interface, though.) There are several alternatives if you want in-process stuff, such as SQLite and HSQLDB.
Of course, if you're feeling really enterprising, there's the open source version of MySQL, which means you could compile it into your app (if you're using C or something that can link to it), but I suspect that's going rather too far. :-)
Yes, works like a charm for this.
Mysqls homepage has lots of info for this.
use SQLite. it is a popular embedded database.
It can be deployed via XCopy and no server installs.
But it can only be used locally. i.e if you later on decide to allow remote access, then you will need to migrate it to MySQL or other databases.
Try xampplite - it will painlessly install MySQL for you (on your local windows machine) as well as apache, php and a few other web apps if you need them.
If you don't want to install a server, you may be interested into Sqlite! It's the most widely deployed embedded database, and it's Public Domain.
http://www.sqlite.org/
Firebird is also an alternative. It's fully ACID-compliant and runs under the Interbase Public License.
http://www.firebirdsql.org/