Archive for December, 2010

Resume a file using rsync over ssh

Sometimes it happens that a file transfer using SCP fails for some reason. Oh no! now you have to start from scratch…

There’s a quick workaround, use rsync over ssh. No rsyncd is needed, and the transfer is secure. It works like this:

rsync -P –rsh=’ssh -pPORT_HERE’ USERNAME_HERE@REMOTE_HOST_HERE:REMOTE_FILE_LOCATION_HERE LOCAL_FILE_LOCATION_HERE

It may still take some time to run based on the file size, but it will certainly take less overall time as it will not transfer the whole file again.

Comments

Export to CSV with MySQL

On Ubuntu, this will create a file in /var/lib/mysql/[DB_NAME]/output.csv

I had to run the query as MySQL root. Didn’t try to find out what permission actually permitted the user to write to the file. It’s probably create table though.


SELECT
v.id, v.title, vc.name, v.slug, v.description
FROM
video v
INNER JOIN
video_category vc ON v.video_category_id = vc.id
INTO
OUTFILE 'output.csv'
FIELDS ESCAPED BY '"'
TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';

Comments