One line: scp mysqldump db and xf data

Marcus

Well-known member
How can I scp both xf's compressed database and data folders in one line for my daily cron job?

I bet I am not the only one moving daily backups to an external server.
 
rsync is better. Why do you need to do it in one line?
If you want, you can create a shell script with 3000 lines and call it in a /etc/cron.d/backup cron file.
 
I love smaller code, for me it's more elegant. I can already scp, dump my db, compress, and name it to yyyy-mm-dd in one line. Just curious how to add gzipped data folders to it.

What is the advantage of rsync? Is it preinstalles in minified CentOS 6?
 
I love smaller code, for me it's more elegant. I can already scp, dump my db, compress, and name it to yyyy-mm-dd in one line. Just curious how to add gzipped data folders to it.

What is the advantage of rsync? Is it preinstalles in minified CentOS 6?
Direct from rsyncs support page:
rsync is an open source utility that provides fast incremental file transfer. rsync is freely available under the GNU General Public License and is currently being maintained by Wayne Davison.

Basically you don't transfer everything but one time. After that, only changed files will be transferred.

To transfer from one of my Forums to my Mac
Code:
#! /bin/bash
cd /Users/tracy
rsync -avz -e ssh username@yourdomain.com:/var/www/forum ~/website
rsync -avz -e ssh username@yourdomain.com:/db_backup ~/website
where the first /db_backup is where mydumper dumps my DB, and /var/ww/forum is the forum, they get transferred to a local directory in my home called website.
 
Last edited:
I love smaller code, for me it's more elegant.
One liners tend to be cumbersome over 80 chars. Personally, I like to use always a shell script where I can write as many lines I like and document inside complex procedures.
 
Top Bottom