2017-05-01 3 views
1

Ich verwende folgenden Code für mysql-Dump. Es wird Datei erstellt database-date.sql.gzMysql-Dump kann mysql-Datei nicht entpacken

date=`date +\%Y\%m\%d\%H\%M\%S` 
user=myuser 
password=password 
backup_dir=/var/backups/mysql/ 
file=database-$date.sql.gz 


mysqldump -u$user -p$password database --max_allowed_packet=512M | gzip - > $backup_dir$file` 

hier Problem wird Dateiformat angezeigt wird, ist unbekannt Format oder beschädigt. I ding es ist aufgrund der Datei nicht ordnungsgemäß erstellt. Was sich geändert hat, sollte ich tun, um eine ordentliche Sicherung großer Datenbankdateien zu machen.

+0

Klingt wie ein Speicherplatz Problem. Wie groß ist die Partition, auf der Sie den Dump speichern und wie viel Speicherplatz haben Sie? – MiiinimalLogic

+0

@MiiinimalLogic 'df -h -x tmpfs -x devtmpfs Dateisystem Größe Benut Verf% auf Montiert/dev/VDA1 30G 13G 17G 43% /' – xrcwrn

+0

Was ist während des Endes der Halde? Zeigt der Befehl, dass Sie fast 100% verwenden? – MiiinimalLogic

Antwort

0

Ich kann das Problem nicht reproduzieren:

Datei: mysql_dump_test.sh

date=`date +\%Y\%m\%d\%H\%M\%S` 
user=$mysql_user 
password=$mysql_password 
backup_dir=/path/to/file/ 
file=$database-$date.sql.gz 
database=mysql 

$ mysqldump -u $user -p$password $database --max_allowed_packet=512M \ 
      | gzip - > $backup_dir$file 

Tester:

$ zcat /path/to/file/mysql-20000101000001.sql.gz | head -20 
-- MySQL dump 10.13 Distrib 5.7.18, for Linux (x86_64) 
-- 
-- Host: localhost Database: mysql 
-- ------------------------------------------------------ 
-- Server version 5.7.18 

/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */; 
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */; 
/*!40101 SET @[email protected]@COLLATION_CONNECTION */; 
/*!40101 SET NAMES utf8 */; 
/*!40103 SET @[email protected]@TIME_ZONE */; 
/*!40103 SET TIME_ZONE='+00:00' */; 
/*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 
/*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 
/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 
/*!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 */; 

-- 
-- Table structure for table `columns_priv` 
--