Source System:
- CentOS 7
- bash shell
- zip
Destination System:
- FTP server
- CentOS 6.4
- bash shell
- unzip
I wrote a script to archive file and send it to FTP server using shell script
#!/bin/bash# Declare no. of daysdays=15# Declare Source path of sql files and Destination path of backup directorydumps=/home/applications/backupbkpdir=/home/applications/backup/olddumps# Find sql dumps of etsfiles=($(find $dumps/*.sql -mtime +"$days"))for file in ${files[*]}do# Move each file into backup dir which is 15 days oldecho "file is: $file\n";mv $file $bkpdir# Find the sql files and compress themcd $bkpdirfilename=$(basename $file)zip $bkpdir/$filename.zip $filename# FTP LoginHOST=a.b.c.dUSER=xxxxPASS=yyyyyREM_DIR=/olddumps/sqlfilesecho "Uploading file via FTP:"ftp -in $HOST <<EOFquote USER $USERquote PASS $PASScd $REM_DIRput $filename.zipbyeEOF# Remove sql files if anyrm $bkpdir/$filenamedone# Remove compressed files which are 6 months oldfind $bkpdir/*.zip -type f -mtime +180 -exec rm {} \;
Now the problem is the compressed file in destination system is not getting extracted using unzip
command and shows the following error:
Archive: emt_bus-08-09-16-03-29.sql.zip
caution: zipfile comment truncatederror [emt_bus-08-09-16-03-29.sql.zip]: missing 49666528 bytes in zipfile(attempting to process anyway)error [emt_bus-08-09-16-03-29.sql.zip]: start of central directory not found;zipfile corrupt.(please check that you have transferred or created the zipfile in theappropriate BINARY mode and that you have compiled UnZip properly)
I used tar
to archive, but no luck. It does not extract file in destination system and shows following error
gzip: stdin: invalid compressed data--format violatedemt_bus-08-09-16-03-29.sqltar: Unexpected EOF in archivetar: Unexpected EOF in archivetar: Error is not recoverable: exiting now
How to fix the issue?