Sponsored Content
Top Forums Shell Programming and Scripting Modification of MySQLDump-files before compression needed Post 302776317 by gogo555 on Wednesday 6th of March 2013 06:52:48 AM
Old 03-06-2013
[Done] Modification of MySQLDump-files before compression needed

Hi @all!

In my MySQL-backup-script I backup and compress every single table with this command:
Code:
/usr/bin/mysqldump --opt database_x table_y | /usr/bin/pbzip2 -c > "/media/BackUpDrive/Backup/table_x.gz"

Unfortunately these files need modification - they have to start with the following line(s):
Code:
CREATE DATABASE  IF NOT EXISTS `Database_X` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `Database_X`;

which is not supported by mysqldump (when exporting single tables)
With the echo-command I can produce the files I want, but all the linebreaks are missing - causing the file to crash at import...
Code:
#!/bin/sh
UseAnweisung="CREATE DATABASE  et cetera";
echo $UseAnweisung `/usr/bin/mysqldump --opt database_x table_y` | /usr/bin/pbzip2 -c > "/media/BackUpDrive/Backup/table_x.gz";

so I wrote a new script using "cat" - but there I could only get through by writing the data to the disk:
Code:
UseAnweisung="CREATE DATABASE  et cetera"
cd /home/backupuser/DB_Backup/tmp
echo $UseAnweisung > USE_Anweisung
/usr/bin/mysqldump --opt database_x table_y > SQL_Anweisung
cat USE_Anweisung SQL_Anweisung | $GZIP -c > "/media/BackUpDrive/Backup/table_x.gz";

so ... is there anybody out there, who can do this without creating the two helper-files?
thx

g

Last edited by gogo555; 03-07-2013 at 11:21 AM.. Reason: Thread marked as [Done] - thx
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Last modification times of files less than 6 months old

How do I get the modification time for files less than 6 months old? (It seems for fles as old or older than this I get to see only the day,month and year. I tried the option -u but it gives me the last accessed time) (1 Reply)
Discussion started by: Abhishek Ghose
1 Replies

2. UNIX for Advanced & Expert Users

Best compression for log files?

I have been doing some investigation into a log file from one of my systems, and the means which I currently use to compress and rotate it. I am looking for something smarter than gzip, faster than bzip2, and that can match or beat "my script" (which is slow as heck, but WAY better compression... (2 Replies)
Discussion started by: jjinno
2 Replies

3. Shell Programming and Scripting

7za compression,urgent help needed!!!

Hi all, I am manipulating a ram disk image.that is 7za compressed... But i somehow am not able to get a hold of the command line for 7za compression and i need urgent help!!! this is what am doing... gzcat /path/to/directory/x86.microroot >/tmp/microroot x=`lofiadm -a /tmp/microroot` mount... (0 Replies)
Discussion started by: wrapster
0 Replies

4. UNIX for Advanced & Expert Users

Help with sorting files according to modification date

Hi, I was very surprised to not be able to find an answer to this question despite my best efforts in Google and elsewhere. Maybe it's a good thing as it forced me to finally become a member in this great forum that i use frequently. Ok my question: I want to be able to sort files inside a... (3 Replies)
Discussion started by: stavros
3 Replies

5. Shell Programming and Scripting

Help needed for mysqldump command

I want to take a backup of a database and redirect the output of the whole process to a log file. I am using the below command: mysqldump -A --add-drop-table > mysql-daily-backup.sql &> /tmp/backup_log/mysql.log Is there anything wrong with the syntax? ---------- Post updated at 08:32 PM... (0 Replies)
Discussion started by: proactiveaditya
0 Replies

6. Shell Programming and Scripting

Rename old files with last modification date

Hi everyone, I have files like file1_Mod.txt, file2_Mod.txt. I want to rename the old files with the last modification date. I write the below script to rename with current date, but I donīt know how to use "date -r" to get the last modification date with the same format I have below... (5 Replies)
Discussion started by: cgkmal
5 Replies

7. UNIX for Dummies Questions & Answers

Modification of Two Files

I have a script that produces two output files each containing the same number of lines <file1.txt> and <file2.txt>. What I need to do is combine both files into a new file <file3.txt> where line 1 of <file1.txt> is put to the right (and on the same line) as line 1 of <file2.txt> and then the same... (5 Replies)
Discussion started by: theref
5 Replies

8. Shell Programming and Scripting

Compression - Exclude huge files

I have a DB folder which sizes to 60GB approx. It has logs which size from 500MB - 1GB. I have an Installation which would update the DB. I need to backup this DB folder, just incase my Installation FAILS. But I do not need the logs in my backup. How do I exclude them during compression (tar)? ... (2 Replies)
Discussion started by: DevendraG
2 Replies

9. Shell Programming and Scripting

Needed shell script to read txt file and do some modification

Hi ...programmers... I need a shell script to perform some specific task.. my txt file looks like this netcdf new { dimensions: XAX1_11 = 11 ; variables: double XAX1_11(XAX1_11) ; XAX1_11:point_spacing = "even" ; XAX1_11:axis = "X" ; float DEPTH(XAX1_11) ;... (19 Replies)
Discussion started by: Akshay Hegde
19 Replies
AMCRYPTSIMPLE(8)					  System Administration Commands					  AMCRYPTSIMPLE(8)

NAME
amcryptsimple - reference simple crypt program for Amanda symmetric data encryption SYNOPSIS
amcryptsimple to be called by Amanda only DESCRIPTION
amcryptsimple calls gpg to perform symmetric data encryption on Amanda backup. amcryptsimple will search for the gpg program in the following directories: /usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin amcryptsimple uses one passphrase to encrypt the Amanda data and uses the same passphrase to decrypt the Amanda backup data. amcryptsimple uses AES256 as the symmetric cipher. HOW TO CREATE PASSPHRASE
Store the passphrase inside the home-directory of the Amanda user ($amanda_user) and protect it with proper permissions: echo my_secret_passphrase > ~$amanda_user/.am_passphrase chown $amanda_user:disk ~$amanda_user/.am_passphrase chmod 700 ~$amanda_user/.am_passphrase NOTES
Choose a good passphrase and protect it properly. Backup data can only be restored with the passphrase. There is no backdoor. If storing and securing passphrase in your environment presents challenges, Amanda provide public-key data encryption through amgpgcrypt. Public-key encryption uses the public key to encrypt and uses the private key to decrypt. SEE ALSO
amanda(8), amanda.conf(5), amcrypt(8), amgpgcrypt(8), amrestore(8), gpg(1) The Amanda Wiki: : http://wiki.zmanda.com/ AUTHOR
Kevin Till <kevin.till@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Amanda 3.3.1 02/21/2012 AMCRYPTSIMPLE(8)
All times are GMT -4. The time now is 10:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy