Problem with backup and copy a database


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with backup and copy a database
# 1  
Old 08-07-2012
Problem with backup and copy a database

Hi,
I have many servers distributed on my customer locations all servers has MYSQL database.

I want to backup database for each server on server at my location using scheduler.

So I create Shell script file to backup and copy the database file from customer server to my server as following:

backup1.sh :
Code:
#!/bin/bash
mysqldump –uuser1 –puser1 mydata | bzip2 > /local/user1/DBBackupScheduler/db-`hostname`_`date +%Y-%m-%d`.sql.bz2


backup2.sh
Code:
#!/usr/bin/expect -f
spawn scp /local/user1/DBBackupScheduler/db-`hostname`_`date +%Y-%m-%d`.sql.bz2 10.10.10.10:/local/user1/DBBackupScheduler/
expect "Password:"
send "user1\n"
expect eof

I make in 2 files to avoid any problem, first file is working fine without any problem the second file make me lose my mind Smilie :

- If I run the file like this:
Code:
User1@host:~> /local/user1/backup2.sh

Output:
Code:
/local/user1/backup2.sh: line 2: spawn: command not found
couldn't read file "Password:": no such file or directory
/local/user1/backup2.sh: line 4: send: command not found
couldn't read file "eof": no such file or directory

- If I run the file like this:
Code:
User1@host:~> expect /local/user1/backup2.sh

Output:
Code:
spawn scp /local/user1/DBBackupScheduler/db-`hostname`_`date +%Y-%m-%d`.sql.bz2 10.10.10.10:/local/user1/DBBackupScheduler/
Password:
/local/user1/DBBackupScheduler/db-`hostname`_`date +%Y-%m-%d`.sql.bz2: No such file or directory
Killed by signal 1

But If I run scp command as it is it working fine without any problem

Please help

Last edited by Franklin52; 08-07-2012 at 04:06 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 08-07-2012
Google 'passwordless ssh' for information on getting scp to work without injecting insecurely-stored plaintext-passwords with the expect third-party brute-forcing tool.
# 3  
Old 08-07-2012
# 4  
Old 08-11-2012
I perefer to use expect, but this idea work great thank you all
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cold Backup of Oracle database.

Hi i need a command to cut the last column from the location in a file and want write a gzip command like cat a.txt /data01/oracle/oradata/vas/data/system01.dbf /data01/oracle/oradata/vas/data/sysaux01.dbf /data01/oracle/oradata/vas/data/undotbs01.dbf... (3 Replies)
Discussion started by: javeedkaleem
3 Replies

2. Shell Programming and Scripting

CRON Job to copy database and replace existing database

I have a reseller account with hostgator, which means i have WHM and Cpanel. I have set up a staging environment for one of my wordpress installations (client website), which is essentially sitting at staging.domain.com (live site is at domain.com). The staging website is a complete copy of the... (1 Reply)
Discussion started by: nzrobert
1 Replies

3. Shell Programming and Scripting

Help with database backup script

Hi, i am very new with linux shell script. my colleague gave a portion of this script, it backups all of your database and there is a option that selects a database that u do not want to include in your backup. what i want is the other way around, i want to select the databases that i only want... (3 Replies)
Discussion started by: makoyski
3 Replies

4. Shell Programming and Scripting

script for backup database

Hello sir, i have used this for taking the database backup 5 * * * * \usr\bin\sh\mysqldump -h localhost -u username-ppassword cms> /home/dbbackup.sql. but it creates a zero size database and in mail it gives error like command not found. Please Help me (3 Replies)
Discussion started by: niva
3 Replies

5. Shell Programming and Scripting

Create database using Backup file

Hi, I have backup file of database in my server. I want to create a that database in the same Mysql Server. How can I do that? Please send the steps to create the database using backup file? Thanks a lot, (1 Reply)
Discussion started by: aish11
1 Replies

6. Shell Programming and Scripting

How to backup a particular Database in MYSQL?

Hi All, Thanks in Advance!! How to backup a particular Databases..through Bash script!! For example i have 6 databases; Anish linux Software Questions Rhce Google these are the databases i have from that i want to take "Anish" and "questions" database backup regularly.... (4 Replies)
Discussion started by: anishkumarv
4 Replies

7. UNIX and Linux Applications

Problem with Database backup

Hi! This is my first post and im not that familiar with UNIX but I'll try to explain my problem.. I have a server here at work running Open UNIX Release 8.0.0 It has a special application on it that I'm trying to run a database backup on. For the last 2 weeks this has failed.. Usually the... (2 Replies)
Discussion started by: TaZ
2 Replies

8. Solaris

Veritas DataBase Backup

hi , we have a monthly policy for database backups . the database is a huge one about 200 GB in size and every month , we shut down the database and take a full system backup . my question is : Is there a way to know that i have taken a valid backup, I need to do something like a test restore... (5 Replies)
Discussion started by: ppass
5 Replies

9. UNIX for Dummies Questions & Answers

Backup of Product Database

HI, I know its scarey me asking this, but system is homegrown and I am just having fun, but at the same time dont want to have tooo much fun where the phrase "little knowledge is dangerous" perfectly fits my actions ;-). I have a couple of packages that are failing to be removed... #... (2 Replies)
Discussion started by: Student37
2 Replies
Login or Register to Ask a Question