Ubuntu Servers :: Su As Backup User Inside Of Bash Script - Lock And Flush Tables On A Mysql Db
Jan 23, 2010
I am attempting to write a backup script that will do the following:
1) lock and flush tables on a mysql db
2) dump the db to a file
3) unlock the tables
4) rsync the file to offsite storage
It all seems to be going well. However, obviously I don't want to setup ssh to the storage server on another network as the root user without a password. so I am attempting to su as the backup user inside of the script but when I try to run the script everything happens as it should until I try to so.. then it jumps out of the script .. akss me to login as the backup user.. proceeds to rsync to the offsite storage it does all this and then resumes execiting the script. it is not going to be setup as a cron job. it will be executed manually. assuming that is the case, how can I get the script to run without prompting for a password?
Here is what I've come up with so far... assuming that the script is run as root and the identity of the backup user will need to be assumed inside the script without perstering the user to enter the backup user's password.
[Code]....
View 8 Replies
ADVERTISEMENT
Jan 15, 2010
policy is to backup mysql with mysql-zrm.However at a certain stage it hangs forever. This is at the "flush logs". I tried this manually and it gave the same result. Even after restarting mysql and the host. After some googling and trying I found out "flush tables with read lock" gives the same result. The tables seem to be MyIsam. I tried with a mysqldump on one server and restore it on a test vm. I used the same config and flush logs still hangs. ALso I tried to change some configuration directives... but with the same result
Edit: btw, I checked the logfile and didn't found anything (/var/log/mysqld.log)
Edit2: I also did myisamchk -s *.MYI (in all direcoties with db files;actually did it with find command) and it did not return anything so datafiles seem ok.
View 4 Replies
View Related
Nov 18, 2009
I want to write the shell script which
1)Finds all the databases in mysql
2)create the folder who ever is the creater of that database or owner of that database. I think the databse starts with username_ so i think i have to split the database name to get folders name . How to do that? backs up the databases belonging to that user.
View 3 Replies
View Related
Jan 19, 2010
I have a scheduled backup to run on our server at work and since the 7/12/09 it has be making 592k files instead of 10Mb files, In mysql-admin (the GUI tool) I have a stored connection for the user 'backup', the user has select and lock rights on the databases being backed up. I have a backup profile called 'backup_regular' and in the third tab along its scheduled to backup at 2 in the morning every week day. If I look at one of the small backup files generated I see the following:
Code:
-- MySQL Administrator dump 1.4
--
-- ------------------------------------------------------
-- Server version`
[code]....
It seems that MySQL can open and write to the file fine, it just can't dump
View 3 Replies
View Related
Sep 20, 2010
When I execute the command below, does mysqldump lock all tables while the backup is in process? I want to make sure this is the appropriate type of backup command for MyISAM database.
mysqldump -h myhostname --default-character-set=utf8 -u root --password=mypassword --opt --single-transaction DBname > /root/backup.sql
View 2 Replies
View Related
Oct 2, 2010
Is there any reason for the mysql user to need bash shell?
From /etc/passwd:
Code:
mysql:x:100:103:MySQL server:/var/lib/mysql:/bin/bash
Will anything break if I change that to /bin/false?
View 2 Replies
View Related
Sep 23, 2010
I am manually backing up my server now with mysqldump and that works but I was wondering about mechanizing the process.
Nirvana would be to dump to a file named with the date
This way I have backups going back over time
View 9 Replies
View Related
Mar 15, 2011
I am currently using a script to backup my Ubuntu 10.04.1 system. The mySQL databases are backed up separately from the the system / data.
My problem is with the mySQL incremental / binary log backups.
The problem is that the binary log file(s) are always named xxxx-bin.1.
Up to about a month ago the binary logs were named xxxx-bin.000001, xxxx-bin.000002, etc.
I did make some changes at about the time that this change in file naming ocurred, but I can not identify what, if any, setting I may have changed that has caused all of the binary log files to always have the same name.
My back up script uses both mysqldump and mysqladmin flush-logs to create the binary logs.
All of the setting for mysqldump and mysqladmin are contained in the my.cnf file.
The my.cnf file contents that are relavent are as follows:
Code:
The statements in the backup script that do the backup are:
mysqladmin flush-logs
or
mysqldump | gzip > $DB_BACKUP_DIR/$ARCHIVE_FILE #Note: delete-master-logs in my.cnf
View 3 Replies
View Related
Apr 25, 2010
I'm trying to get a password in a bash script for mysql user creation. But sometimes a get a non-alphanumeric character(s) in the password, and mysql failes with that. I tryed with apg -EO0Il1`~!@#$%^&*()_+-=[];./{}|:"'<>? but failed. I tryed with sed 's/[^a-zA-Z2-9]//g' , but at that moment the minimum password lenght failed. I'm also fine when there is a better alternative then apg.
View 2 Replies
View Related
Jun 14, 2010
I am using Joomla and a script within it. That Script is suppose to copy tables from one DB to another.
Code:
Error(1) [1142] query [CREATE OR REPLACE VIEW test_users AS SELECT * FROM `localiz_master`.`jos_users`]. DB Error: CREATE VIEW command denied to user 'localiz_master'@'localhost' for table 'test_users' SQL=CREATE OR REPLACE VIEW test_users AS SELECT * FROM `localiz_master`.`jos_users`
Error [1142] retrying query [CREATE OR REPLACE VIEW test_users AS SELECT * FROM `localiz_master`.`jos_users`]. DB Error: CREATE VIEW command denied to user 'localiz_master'@'localhost' for table 'test_users' SQL=CREATE OR REPLACE VIEW test_users AS SELECT * FROM `localiz_master`.`jos_users`
localiz_master: name of the DB from which data is suppose to be copied.
jos_users: name of the table form the main DB.
localiz_master: user for the DB.
localhost: host
test_users: name of the table to be created.
We do have phpmyadmin but the user's table is hidden. What SSH command we might run to make localiz_master user have access to all the databases.
View 6 Replies
View Related
Jan 24, 2011
I'm running Mysql server. I need to know if is possible to generate an alert (email) when in the database are locked tables.
Is that possible?
View 3 Replies
View Related
Dec 11, 2009
Can't single the cause of the error.
mysql> CREATE TABLE Shipment (
-> Shipment_ID INT(10) NOT NULL,
-> Delivery_ID INT(10) NOT NULL,
-> Customer_ID INT(10) NOT NULL,
-> Driver_Employee_ID INT(10) NOT NULL,
-> Consignee VARCHAR(255) NOT NULL,
-> Payment_Method VARCHAR(255) NOT NULL,
-> Payment_Received VARCHAR(1) NOT NULL,
-> CONSTRAINT PRIMARY KEY (`Shipment_ID`)
-> FOREIGN KEY (`Delivery_ID`) REFERENCES `Delivery`(`Delivery_ID`)
-> FOREIGN KEY (`Customer_ID`) REFERENCES `Customer`(`Customer_ID`)
-> FOREIGN KEY (`Driver_Employee_ID`) REFERENCES `Driver`(`Driver_Employee_ID`)
-> )ENGINE=InnoDB DEFAULT CHARSET=latin1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOREIGN KEY (`Delivery_ID`) REFERENCES `Delivery`(`Delivery_ID`)
FOREIGN KEY (`C' at line 10)
View 4 Replies
View Related
Aug 23, 2010
I am looking for the best solution for backup, I want to backup the /home/user.I know about rdiff, and rsync but is there a better solution for backup these folder.And the security must be good, The backup I want to make is from a server to a server in a datacenter.Both servers are running on UBUNTU 9.10.
View 6 Replies
View Related
Dec 21, 2010
Is there somebody knows about how to convert or changes tables on MySQL ?
I was working a lot of months with MySQL with localhost. And now will setting up to MySQL database Cluster. I was success to setup the clustered with "MySQL-Cluster-gpl-7.0.16" on CentOS environment.
But, when I tried to restore database from localhost to clustering system, I get this message error when do changes from MyISAM to NDBCLUSTER Tables "Error, Can't create table 'dbname.sql-3ef9_a8'(errno: 708).
How can I changes the table?
View 7 Replies
View Related
Jul 28, 2010
I have recently upgraded my Debian unstable to the new custom 2.6.34 kernel. The system is unresponsive and top shows two processes (flush-8:0 & flush-8:16) taking up most of the cpu time.
View 3 Replies
View Related
Sep 28, 2009
I am running a mysql 5.0.41 community edition server.i have a user x and i need to set max connection limit for the user... Can any one give the correct syntax to update the current user to include max connection for the user x.
View 1 Replies
View Related
Nov 18, 2010
Let's say we have a file tables listing all the tables of a database.Can I use grep and mysqldump to dump only tables with certain prefix? I tried
grep prefix_ tables | mysqldump -u root -p databasename > db.sql
but this takes all the tables..
View 1 Replies
View Related
Feb 10, 2010
Thoroughly repeatably, OpenOffice locks up on me when scrolling inside documents. Here's the breakdown:
* Only happens when actively in the process of scrolling
* Doesn't matter if you use keyboard, mouse wheel, drag the scroll bar, or click the scroll arrows
* Always happens within 15 minutes of steady use
* Happens in both writer and calc -- haven't tested the others
* OOo freezes up and no longer repaints the window or responds to anything
* gnome-session peaks out at 100% CPU and stays there
* Currently running application continue to work fine
* Most applications (gnome-terminal, firefox, koffice) can no longer be launched
* Some applications (abiword) can still be launched
* Launching from icons brings up the spinner, but nothing else happens
* Launching a GUI app from a terminal, it looks like it runs on CLI, but nothing ever happens in the GUI proper
* X starts leaking descriptors and thus chewing up drive space at ~1M/s
Killing X and bringing up a new session puts everything back to normal, including CPU usage and drive space. This happens every time on my 64-bit Intel laptop and has persisted through several X/OpenOffice/kernel updates. It never happens on my 32-bit Intel desktop.
View 3 Replies
View Related
Mar 25, 2010
When i connect windows server 2003 from ubuntu these error displayed .When i installing the tsclient, by executing these following command from a Terminal window:
sudo apt-get install tsclient
When i run these command the following error displayed.
E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
View 1 Replies
View Related
Jan 30, 2011
I installed mediawiki the other day and went with the default innodb option. However a week later something went wrong. And since I have scripts that nightly backup /var/ I just copied the backup of /var/lib/mysql/wikidb/ (as I've done with MyISAM). Then when I connect the wikidb database. I can see the tables (via "show tables"), but when I do any query with them (check table X, select * from X) I get:
Code:
Table 'wikidb.X' doesn't exist I've since read that can can't just copy the database directory like MyISAM, and there appears to be no way that I can find to restore or fix Innodb, without a dump of the data. And I never got a chance to do a mysqldump of the data. So has anybody got any idea how I can at least view the "page" table from the files I've backed up in /var/lib/mysql/wikidb/ ?
View 1 Replies
View Related
Mar 26, 2010
I set up a servber on my local machine, & also PHp - Both working fine.I'm trying to load up MYSQL i have installed it, & *can* start/stop the server. however if I do anything else with it, I get this error :-
Quote:
root@gordon-desktop:~# sudo mysqladmin -u root -h localhost password MYPASSWORD
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
Query :-
1) How do I know MYSQL is actually active ? (apart from the message it says that its statrted (or stopped).
2) Is there a way to
a) Find out the usernames that are recorded on the MYSQL server ?
b) set / RESET the 'root' username (I know MYSQL root user is different to PC root user)
c) anything else I can do on the PHP / website code to see if MYSQL is working
(as yet, no tables / databases etc have been set up - as I can't get past this error message - I get the same error when setting up a database.)
Ps I did allow my usermname (when logged in to ubuntu) to edit / create files in the /usr/www/ directory (but it is still OWNED by 'root' - that directory)
View 4 Replies
View Related
Apr 28, 2011
I've noticed something, and hoped there was a work around.when I write a simple bash script, and run it, if I close the terminal i ran the bash script inside, the bash script stops. What are the solutions for this? Basically I want to run my bash script and close the terminal, keep the bash script running.
View 6 Replies
View Related
Jan 5, 2010
If any real hassle using a database between web sites. Not obviously phpBB but rather various projects that need a common read access to maintain a relation
View 1 Replies
View Related
May 5, 2011
I've been googling this for a while now, and trying different examples, like:
iptables -A INPUT -s 3.2.1.0 -j DROP
iptables -A INPUT -s 3.2.1.0/24 -j DROP
service iptables restart
[code]....
View 12 Replies
View Related
Aug 7, 2010
How do I create a new mysql user and a mysql database at the shell prompt?
View 1 Replies
View Related
Aug 2, 2010
I'm trying to setup wordpress on my server, which of course I need mysql for. I setup a database the other day, which worked perfectly, but I had to start again as I put some information in wrong. Now, I can create a database fine, but when I run
Code:
GRANT ALL ON wordpress.* TO wordpress@localhost IDENTIFIED BY "password";
I get the output:
[code]...
View 13 Replies
View Related
May 4, 2011
im pretty sure this is a remedial task for many of you but im having an issue with arrays from a shell script being accessed in an awk command. im pretty good with shell scripting but i am embarrassingly unfamiliar with awk. so here's the meat of the script...
Code:
I am trying to take an input file of ip addresses and corresponding netmasks and put it into a format to be loaded onto a juniper switch. the result should look something like this.. x.x.x.x/netmask using the cidr notation. no matter what subnet is provided though, /32 always gets appended to the end of the ip even when it should be /16, /24, etc... also, the cisco part works fine so that doesnt need any attention.
View 5 Replies
View Related
Oct 23, 2010
I want to do the following redirectin inside a bash script :
1. all the stdout will be redirected to a /tmp/log
2. all the errors will go to the stderr and also to the /tmp/log.
The following inside a bash script is not working, WHY and HOW to do it:
Rest of the bash script.
View 4 Replies
View Related
Jun 8, 2011
I have trouble with using an alias inside aash function. I would like to ssh into multiple machines by executing:ssh machine To achieve this, I put something like the following into my ~/.bashrc:
alias machine='user@machine'
ssh()
{
[code]....
View 1 Replies
View Related
Dec 30, 2010
how do i use bash shell scripts inside php.I am just trying to call a simple cp command using php. Its not doing anything.
View 2 Replies
View Related