LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-03-2007, 07:37 PM   #1
bskrakes
Member
 
Registered: Sep 2006
Location: Canada, Alberta
Distribution: RHEL 4 and up, CentOS 5.x, Fedora Core 5 and up, Ubuntu 8 and up
Posts: 251

Rep: Reputation: 32
Question cronjob --> my script to scp to remote server


Hi there! I am hoping that someone can explain why my script isn't working correctly. I have created the following script to make a backup of my web server, tar it, zip it from the backup file, then export the tar.gz bk file and remove the original backup file of the web server, keeping a copy on both the production server and remote backup server..... PLEASE HELP!

#!/bin/bash
####################################################
#
# Author: Brendan Skoreyko
# File Name: plesk_full_bk.bsh
# Created: June 12, 2007
# Usage: to take a full backup of the Plesk Server
#
####################################################

TIMESTAMP=`date +%Y%m%d.%H%M`

echo "Stating full backup of Plesk Server Settings" >> /root/log/plesk_bk.log
date >> /root/log/plesk_bk.log
cd /usr/local/psa/bin
./pleskbackup --all /backup/plesk_backup/FULL_BK${TIMESTAMP}
echo "Backup of plesk server settings complete......" >> /root/log/plesk_bk.log
echo "Compressing plesk server settings backup file....." >> /root/log/plesk_bk.log
tar --verbose --create --gzip --file /backup/plesk_backup/plesk_bk_${TIMESTAMP}.tar.gz /backup/plesk_backup/FULL_BK${TIMESTAMP} >> /root/log/plesk_bk.log
echo "Exporting compressed file to SDM.SRV" >> /root/log/plesk_bk.log
scp /backup/plesk_backup/plesk_bk_${TIMESTAMP}.tar.gz root@my_server:/home/brendan/backup
echo "Removing plesk backup file, keeping compress backup file" >> /root/log/plesk_bk.log
rm -f /backup/plesk_backup/FULL_BK${TIMESTAMP}
echo "Backup and Export complete!" >> /root/log/plesk_bk.log


Now the script runs fine in my crontab but it is not exporting the file to the remote server. I have ran the script once and scp'ed it to the remote server but it seems as though it hasn't remembered there scp password. When ever I run the script manually it will transfer the backup file to the remote server, it does not scp it when I run it daily in the crontab (backup works it just doesn't scp). ANY AND ALL HELP would be greatly appreciated.

Cheers!
 
Old 07-04-2007, 02:11 AM   #2
baikonur
Member
 
Registered: Oct 2005
Location: germany
Distribution: debian
Posts: 255
Blog Entries: 5

Rep: Reputation: 30
do you have to enter a p-word when you manually scp to the remote machine?
if yes, you'll have to exchange rsa (or dsa) keys between the servers to allow communication w/o password.
 
Old 07-04-2007, 05:36 AM   #3
Balakrishnan84
Member
 
Registered: Feb 2007
Location: Bangalore, India
Distribution: Fedore Core 6
Posts: 41

Rep: Reputation: 15
Quote:
Originally Posted by baikonur
do you have to enter a p-word when you manually scp to the remote machine?
if yes, you'll have to exchange rsa (or dsa) keys between the servers to allow communication w/o password.
Check the above comment and still if you face some problem, then log the process in some file.
Log it for scp also...like.....

scp <source> <dest> 2>some_log_file

Last edited by Balakrishnan84; 07-04-2007 at 05:41 AM.
 
Old 07-04-2007, 06:16 AM   #4
baikonur
Member
 
Registered: Oct 2005
Location: germany
Distribution: debian
Posts: 255
Blog Entries: 5

Rep: Reputation: 30
btw,

let ssh run on a port != 22;
rid yourself of tons of auth.log logfile entries.

Last edited by baikonur; 07-04-2007 at 06:24 AM.
 
Old 07-04-2007, 06:42 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Which user is running the cron job?
This is important, since cron will look for the ssh keys in the user's home directory, which can overridden by adding HOME=/some/dir to the cron job settings (crontab).
 
Old 07-04-2007, 04:25 PM   #6
bskrakes
Member
 
Registered: Sep 2006
Location: Canada, Alberta
Distribution: RHEL 4 and up, CentOS 5.x, Fedora Core 5 and up, Ubuntu 8 and up
Posts: 251

Original Poster
Rep: Reputation: 32
Thumbs up scp-cronjob -- server backup script

You guys/gals are great!

I found the information I needed via Google at the following link: http://www.spaceprogram.com/knowledge/cron_scp.html

Last night, after thinking long and hard I remembered that you have to do something with the server RSA key (of course over night I see that many people have responded with the answer I needed), I Googled it and there it was (duh everyone knows that they should Google first, but I was a little impatient)! Thank you all for your comments, all it took was for me to generate the RSA key and copying it to the remote server and testing the scp which did not require a password.

As always everyone in this forum rocks! If anyone needs help setting up a script like the one I have I would be glad to help, just PM me.

Cheers.....
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SCP: Copy file from remote linux server onto a windows machine? Tony Empire Linux - Newbie 19 06-04-2013 05:13 AM
bash script problems: scp/ssh from the node of a cluster to the other server frankie_DJ Programming 2 01-27-2007 06:29 PM
sftp script via cronjob ?? OzTEXS Linux - Security 21 12-28-2006 03:38 PM
Cronjob / script question nazs Linux - General 1 12-21-2006 01:45 PM
cronjob php script MrSako Linux - General 1 08-27-2006 07:30 PM


All times are GMT -5. The time now is 06:40 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration