Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Mar 26, 2009 8:27 am 
Offline
Senior Member

Joined: Wed Jan 21, 2009 7:13 pm
Posts: 126
Location: Portugal
Hi,

I generate nightly backups to S3, but I would like to setup a routine so that when I'm on my mac at home, it will ssh to my linode and download a file (mysql dump) with a name like "database-26-03-2008.tar.gz".

Thanks

n


Top
   
 Post subject:
PostPosted: Thu Mar 26, 2009 9:07 am 
Offline
Senior Member
User avatar

Joined: Sat Oct 16, 2004 11:13 am
Posts: 176
To generate dump + trasnfer over ssh to home pc:
Code:
ssh -t username@server "mysqldump --username=username --password=password database | gzip -c -9 -f" >  databse-`date %d-%m-%y`.gz 

To simply trasnfer a file:
Code:
scp user@password:path/to/datbase.gz database-`date %d-%m-%y`.gz


Top
   
 Post subject:
PostPosted: Tue Mar 31, 2009 7:00 pm 
Offline
Senior Member

Joined: Wed Jan 21, 2009 7:13 pm
Posts: 126
Location: Portugal
Hi,

I was trying to rsync the backup folder in my linode using this command:

rsync -av --progress --inplace --rsh='ssh -pxxxx' user@remote local

This works, but now when I schedule the cron in my Mac is doesn't work because the remote user is different than the local user who run the cron locally.

How am I able to run the cron?
Maybe using ssh keys?


Top
   
 Post subject:
PostPosted: Tue Mar 31, 2009 7:11 pm 
Offline
Senior Member

Joined: Wed Jan 21, 2009 7:13 pm
Posts: 126
Location: Portugal
Ok,

Generating keys solved the problem :)


Top
   
 Post subject:
PostPosted: Sun Jan 15, 2012 8:02 am 
Offline
Newbie

Joined: Sun Jan 15, 2012 6:47 am
Posts: 2
Thanks for the tip! I now use it to backup my Linode database with mysqldump and download it to my computer automatically using scp (ssh key) with a local cron job.

Of course, this only works if my own computer is turned on at 12:15, but it normally is. Both Linode and my own computer are running Ubuntu 10.04 LTS.

## ONLINE: create a cron job to dump my MySQL database to /tmp directory
# every day, at 12:05
05 12 * * * mysqldump -u USERNAME -p'PASSWORD' DATABASENAME | gzip -c > /tmp/DATABASENAME_database.sql.gz

## LOCALLY: download the file with scp
# every day, at 12:15
15 12 * * * scp USERNAME@SERVER:/tmp/DATABASENAME_database.sql.gz ~/.mysql-dump/`date +\%Y/\%m`/DATABASENAME-online-`date +\%Y-\%m-\%d-\%H.\%M`.sql.gz

The local cron job puts the file in the folder ~/.mysql-dump/YEAR/MONTHNAME/
I manually create the years like this ~/.mysql-dump/2012 and have another cron job which creates the month when needed. It wont overwrite it if it already exists:
# every day, at 12:00
00 12 * * * mkdir -p ~/.mysql-dump/`date +\%Y/\%m`/


Top
   
 Post subject:
PostPosted: Mon Jan 16, 2012 2:16 pm 
Offline
Junior Member

Joined: Wed Oct 06, 2010 2:41 pm
Posts: 20
rn3000 wrote:
Of course, this only works if my own computer is turned on at 12:15, but it normally is. Both Linode and my own computer are running Ubuntu 10.04 LTS.


Anacron is a utility that works in conjunction with cron to make sure tasks like this get run the next time you turn on your computer if they were missed because it was off.


Top
   
PostPosted: Sun Jan 20, 2013 6:33 am 
Offline
Newbie

Joined: Sun Jan 15, 2012 6:47 am
Posts: 2
Thanks for sharing. I didn't subscribe to this thread, so I just saw your post today, a year later :)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group