Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: RHEL 4 and up, CentOS 5.x, Fedora Core 5 and up, Ubuntu 8 and up
Posts: 251
Rep:
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.
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.
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.
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).
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.