A straight-forward question:
Could you please guys give me an alternative to this tar command, using gunzip ?
tar -C /var/cpanel/easy/apache/custom_opt_mods -xzf custom_opt_mod-mod_geoip.tar.gz
I want this because when I am trying to run that command I get with this:
gzip: stdin: not in gzip format tar: Child returned status 1 tar:
Error is not recoverable: exiting now
Thanks
Related
For my uni I need to write a simple script that makes backups of few directories and move them to another directories. I'm very new to Linux so I'm kinda lost. Before that, they showed how to archive with tar and compress with gzip, so I'm assuming that's how I need to do those backups. It is also beginner level, so the script should be as simple as possible.
Here's my script:
#!/bin/bash
echo
directories="work/ extract/ test/"
for directory in $directories
do
tar --create --gzip --file= ~/backups "$directory".tgz $directory
done
And that's the outcome:
pi#raspberry:~ $ ./my_backup.sh
tar: Removing leading `/' from member names
tar (child): : Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: : Cannot write: Broken pipe
tar: Child returned status 2
tar: Error is not recoverable: exiting now
tar: Removing leading `/' from member names
tar (child): : Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: : Cannot write: Broken pipe
tar: Child returned status 2
tar: Error is not recoverable: exiting now
tar: Removing leading `/' from member names
tar (child): : Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: : Cannot write: Broken pipe
tar: Child returned status 2
tar: Error is not recoverable: exiting now
I can only guess it's something to do with the names, because '/' is not allowed in names, I think, but I don't know how to remove it. I asked this question on my uni's forum, but nobody answered.
Thanks a lot for your help.
#!/bin/bash
set -e
directories=(work extract test)
for directory in ${directories[#]}; do
tar -czf "${HOME}/backups/${directory}.tgz" "${directory}"
done
I think you could just put the directories into a list do iterate through them via a for loop.
So instead of
directories="work/ extract/ test/"
write
directories=("work" "extract" "test")
if you use the script in the same directory as the directories you need to backup are.
I wasnt able to test it yet, but I think it should work this way.
i want to extract tar file.
but, terminal is error output.
i want to solve the error.
could you help me?
this is terminal cmd
$ tar xvzf test.tar -C /dir/
this is error output
# gzip: invalid magic
# tar: Child returned status 1
# tar: Error exit delayed from previous errors
You are running tar xzvf, which extracts a compressed tar, but the filename given is tar, which is just a tar file, not compressed. Try without the z.
tar xvf ...
I am having difficulty trying to backup my 'my_work' directory into my destination 'Backup' directory. I tried running the script, but it does not seem to work. This is the script that I have written :
#!/bin/bash
SRCDIR="/home/student/Documents/my_work/"
DESTDIR="/home/student/Backups/"
FILENAME=backup1-$(date +%-Y%-m%-d)-$(date +%-T).tgz
tar --create --gzip --file=$DESTDIR $FILENAME $SRCDIR
This is the output I received :
tar: backup1-201576-10\:24\:17.tgz: Cannot stat: No such file or directory
tar: Removing leading '/' from member names
tar (child): /home/student/Backups/: Cannot open: Is a directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
I can't seem to find a solution to this, please help
Just make a subtle change in your script:
Change
tar --create --gzip --file=$DESTDIR $FILENAME $SRCDIR
to
tar --create --gzip --file=$DESTDIR$FILENAME $SRCDIR
Notice there is no space between $DESTDIR and $FILENAME. To suppress tar: Removing leading '/' from member names, you may use the -P flag cautiously.
Also, it'd be nice to replace colons in the filename with underscores or dashes. Colon is a reserved character that is also used in PATH and may cause confusion.
I am no expert at this, but I wanted to created a script that I could turn into a cron job to run a backup of the websites and database on my home server. I found this script and customized it to my settings:
#!/bin/sh
THESITE="ic.sitescribersdev.com"
THEDB="zadmin_ironcowboy"
THEDBUSER="xxxxxx"
THEDBPW="xxxxxx"
THEDATE=`date +%d%m%y%H%M`
mysqldump -u $THEDBUSER -p${THEDBPW} $THEDB | gzip > /var/zpanel/hostdata/zadmin/public_html/$THESITE/backups/files/dbbackup_${THEDB}_${THEDATE}.bak.gz
tar czf /var/zpanel/hostdata/zadmin/public_html/$THESITE/backups/files/sitebackup_${THESITE}_${THEDA TE}.tar -C / var/zpanel/hostdata/zadmin/public_html/$THESITE
gzip /var/zpanel/hostdata/zadmin/public_html/$THESITE/backups/files/sitebackup_${THESITE}_${THEDA TE}.tar
find /var/zpanel/hostdata/zadmin/public_html/$THESITE/backups/files/site* -mtime +5 -exec rm {} \;
find /var/zpanel/hostdata/zadmin/public_html/$THESITE/backups/files/db* -mtime +5 -exec rm {} \;
I tried to run it in ssh to see if it would output the data but I get this error:
arudd#new-host-3:/var/zpanel/hostdata/zadmin/public_html/ic_sitescribersdev_com/backups$ sudo sh backup.sh
: not found2: backup.sh:
: not found8: backup.sh:
: Directory nonexistent_zadmin_ironcowboyar/zpanel/hostdata/zadmin/public_html/ic.sitescribersdev.com
'#'localhost' (using password: YES) when trying to connectwboy
: not found10: backup.sh:
tar: var/zpanel/hostdata/zadmin/public_html/ic.sitescribersdev.com\r\r: Cannot stat: No such file or directory
tar (child): /var/zpanel/hostdata/zadmin/public_html/ic.sitescribersdev.com\r/backups/files/sitebackup_ic.sitescribersdev.com\r_1107141435\r.tar: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
: No such file or directoryc.sitescribersdev.com.sitescribersdev.com
: not found13: backup.sh:
find: missing argument to `-exec'
find: `/var/zpanel/hostdata/zadmin/public_html/ic.sitescribersdev.com\r/backups/files/db*': No such file or directory
Any help on what I am doing wrong to get this to work would be awesome.
Thanks!
I figured it out. It was throwing out errors because the script was made in windows. All I had to do was install and run dos2unix on the script and then it worked like a charm!
I downloaded a couple of versions from
http://swiftmailer.org/downloads/archive
(tar.gz) but the archive manager says
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors
when I try to open it. Any ideas?
Try:
gzip -d file.tar.gz
then:
tar -xf file.tar
This was taken from:
http://fosshelp.blogspot.com.au/2012/04/solution-tar-this-does-not-look-like.html
Or just tar xzf file.tar.gz. Easier, faster, and takes less disk space.
Update:
I don't see why that doesn't work, but ungzipping first does. In that case, it would be better to:
gzip -dc file.tar.gz | tar xzf -
which at least uses a pipe to avoid uncompressing and reading back from mass storage.