FAQ Database Discussion Community


Create a .tar file from a array in PHP

php,linux,tar
I want to create a .tar file from an array in PHP which has the path of the files I want to compress. Array ( [0] => Array ( [img] => 1000e5d5771dd2c08bb368faef3e44944.jpg ) [1] => Array ( [img] => 10011633ba1169e1c7a67b31ad41df0c8.jpg ) [2] => Array ( [img] => 100155e447db12dc3a0d3cc3a4bd55f10.jpg ) )...

Exec php tar command to backup website dynamically

php,linux,exec,tar
I'd like to backup my website using tar command and exec of php and I wrote a small script to do that but nothing happens... where I fault? I have php 5.6.5 and hosting linux that have exec enabled and tar command available... so I have all materials for writing...

Insert variables in a “TarFile Object” in Python

python,variables,object,tar
I want to insert some variables in a "TarFile Object". What is the correct way? Thanks. import tarfile import datetime import time today = datetime.date.today() timetoday = time.strftime("%H:%M:%S") print today, timetoday print timetoday dirname="notes" dirnamefullpath='/var/log/something' print today, timetoday, 'Creating archive:', dirname tar = tarfile.open("/backups/files/sitebackup-pythontest-[today]-[timetoday]-[dirname].tar.gz", "w:gz") for name in [dirnamefullpath]: tar.add(name)...

Tar all folders and files except folders with a specific name

unix,tar,exclude
Im trying to tar a folder with subdirectories but i want to exclude all folders with the name "log". I have search and seen that the tar command have the option of --exclude the problem is that this option required to be specific folder not a dynamic one. Is there...

how to solve TAR: CANNOT MKDIR PERMISSION DENIED

permissions,tar,mkdir
File permissions I have a file data.tgz which I want to uncompress. -rw-r--r-- 1 username group 20342951248 mai 18 11:50 data.tgz Directory permissions Directory where file is located drwxrwxr-x 3 username group 4096 juin 1 17:16 directory/ Uncompress When I try to uncompress the file by using the following command:...

wget not following the flashplayer download link

wget,tar,flash-player,gz
I'm trying to write a script that will download the latest version of the flashplayer tarball and unpack it. Should be simple enough I thought. But the "Download now" link on this page resolves to "https://get.adobe.com/flashplayer/download/?installer=Flash_Player_11.2_for_other_Linux_(.tar.gz)_64-bit&standalone=1 and when I execute the following line wget "http://get.adobe.com/flashplayer/download/?installer=Flash_Player_11.2_for_other_Linux_(.tar.gz)_64-bit&standalone=1" it yields --2015-05-08 08:56:49--...

Python: unpack android backup?

android,python,backup,tar,zlib
I'd like to unpack an Android backup file using python. According to http://nelenkov.blogspot.com/2012/06/unpacking-android-backups.html an unencryted adb file can be decompressed using dd if=mybackup.ab bs=24 skip=1|openssl zlib -d > mybackup.tar and tar xvf mybackup.tar Can these can be done in python? Python has zlib, gzip and tarfile, which seem as if...

How to remove a version number from a folder

bash,shell,tar
I have builds of a installer in a directory like this: install-0.1.tar.gz install-0.2.tar.gz install-0.3.tar.gz And I want to run a line that unzips one of the tarballs into a folder like so: install install-0.1.tar.gz install-0.2.tar.gz install-0.3.tar.gz Unzipping and renaming the folder is the important bit. Thanks for the help...

Python tarfile and zipfile producing archives with different MD5 for 2 identical files

python,zip,md5,tar
I am trying to ensure that 2 archives with the same files inside produce the same MD5 checksum. For example, file1.txt and file2.txt have identical content, the only difference between them is creation time. However, they produce the same MD5: >>> import md5 >>> md5.md5(open("file1.zip","rb").read()).hexdigest() 'c99e47de6046f141693b9aecdbdd2dc2' >>> md5.md5(open("file2.zip","rb").read()).hexdigest() 'c99e47de6046f141693b9aecdbdd2dc2' However,...

Allow access to protected file through PHP

php,curl,header,tar,gz
I have a set of tar.gz files inside a folder protected against http access via .htaccess. I wish to allow direct curl downloading of these files via http. I have done this to things like images by setting the header information to something like: $file='/some/file/protected/by/htaccess.png'; header("Content-type: image/png"); readfile($file); My question:...

Error when `tar` a `.zip` on Linux

linux,osx,zip,tar
I zipped a directory on my Mac OSX with the zip command line and -r option. I scp the .zip to a cluster operating on Linux. If I try to decompress the .zip with tar -vxzf foo.zip on my machine it works. But the same command doesn't work on the...

How can I debug the Bourne Shell with gdb?

bash,gdb,tar
I built a toolchain script to prepare a Linux build environment. The script can be found here: https://github.com/mynameismevin/prometheus/blob/toolchain/ptool-make.sh The script runs perfectly until after the Perl section around line 416. After Perl is done, when it goes to unzip sed, it complains with this error: tar (child): sed-4.2.2.tar.bz2: Cannot open:...

create tar file from stdin

pipe,tar
I want to backup mysql to a tape on-the-fly. Some like mysqldump|tar --filename=mysqlbackup.sql > /dev/tape I want the tape has content a tar file and this file has content "mysqldump.sql" So a command "tar -t < /dev/tape" should output mysqldump.sql I don't want at first save mysqldump to file, because...

How to extract a variety of zip files without knowing the extension in bash

bash,zip,tar
I'm writing a bash script which needs to handle a bunch of zip files with different possibilities (primarily tar.gz, zip, and rar). Is there a tool I can get that does this, so I could call "toolname filename", and if not, how do I determine the extension of a file...

BusyBox tar: append workaround given limited disk space?

linux,bash,tar,busybox
I'm on a Linux system with limited resources and BusyBox -- this version of tar does not support --append, -r. Is there a workaround that will allow me to [1] append files from directory B to an existing tar of files from directory A after [2] making the B-files appear...

Read from a tar.gz file without saving the unpacked version

ruby,ruby-on-rails-4,tar,gz
I have a tar.gz file saved on disk and I want to leave it packed there, but I need to open one file within the archive, read from it and save some information somewhere. File structure: base_folder file_i_need.txt other_folder other_file code (it is not much - I tried 10mio different...

using tar command to create a compressed directory with date

shell,command,ubuntu-12.04,tar
I need to run this command in ubuntu 12.04 32bit tar -zcvf $ BACKUP_DIR/backup_`date "+% d-% m-% Y"`.tgz $HOME/tmp but I can't obtain the directory with date. When I execute the command the shell returns date +%d -%m -%y: the order is not found tar: Eliminating the `/ 'initial of...

Linux: Stopping tar command?

linux,tar
Uh I badly messed up today, I was going to backup my whole website folder (public_html) and didn't realize that it was 24GB, now it's eating up disk usage and I have no idea how to stop it. The command I used was: tar -cvpzf /home/mywebsite/public_html/backup.tar.gz /home/mywebsite/public_html/ I deleted the...

Linux: how do I tar to a specific location? [closed]

linux,tar
I am currently backing up my system. If I use > tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found--exclude=/backup.tgz --exclude=/mnt --exclude=/sys / It says the system doesn't have enought space. Right now, I have mount a usb in directory ~/mnt/sdc1 How do I tar the backup.tgz to this specific location?...

How to get uniform compression while using xz compression in Java?

java,compression,tar,lossless-compression,xz
I am trying xz compression in Java. Using the xz 1.5 compression library, the commons io 2.4 library and the commons compress 1.8.1 library. I tried to run the code below which gave me very inconsistent results . Over 70% for text, Under 0.1% for audio and video files (1-compressed/original...

Compress a folder and exclude sub-directories in terminal

linux,command-line,terminal,compression,tar
I'm trying to compress a folder using the command below and exclude multiple sub-folders as it has over 10GBs which i don't need: [email protected]:/var/www$ tar -zcvf master16march.tar.gz master -x "master/media/com_easysocial/photos/*" "master/media/com_easysocial/avatars/*" "master/media/com_easysocial/tmp/*" "master/media/com_easydiscuss/attachments/*" "master/images/joomcareer/*" And i got this error: tar: You may not specify more than one `-Acdtrux' or `--test-label'...

Extract .tar.gz file in Build.scala (without external libraries)

scala,sbt,gzip,tar
There are a lot of questions about extracting .tar.gz files in Java/Scala but all of them involve using some library to extract the tar file. GZIPInputStream is part of Java SE but I don't know of a way to extract tarballs using Java SE. As far as I can tell,...

Maven AntRun plugin include root folder on tar

maven,tar
on my project I need to create a tar with the full content of a folder. I do it with the maven antRun plugin. My problems is that the main root isn't in to the tar. How to insert the folder? Es. I have Target ---temp ---Example ------aaa.png ------bbbb.png ------rsc...

Tar.gz and encrypt folders

shell,folder,tar,gnupg
I have a lot of folders I'd like to backup on a remote location. I'd like to tar.gz and encrypt all of these, [if possible] in a single command line. So far, I've successfuly did half the work, with find . -type d -maxdepth 1 -mindepth 1 -exec tar czf...

What is the best way to compare tar archives in junit testing

java,junit,tar,apache-commons-compress
I am attempting to create jUnit tests for some code that generates tar files. During testing I will be creating a variety of tar files and comparing them to "Gold" tar images of the expected output. I have been struggling to create an assertTarEquals(String file1, String file2) function, and was...

Node.js - Browserify: Error on parsing tar file

javascript,node.js,parsing,tar,browserify
I'm trying to download a tar file (non-compressed) over HTTP and piping it's response to the tar-stream parser for further processing. This works perfect when executed on the terminal without any errors. For the same thing to be utilized on browser, a bundle.js file is generated using browserify and is...

Find files and tar them with trailing or leading space in their name

linux,bash,tar
I have a script, that tries to archive the contents of a directory with tar: #!/bin/bash find /root/files -type f -name "1*" -print0 | while read -d $'\0' file do MYDIRNAME=$(dirname "${file}") MYFILENAME=$(basename "${file}") MYMODIFYDIR=$(echo "$MYDIRNAME" | sed 's/^\///' | sed 's/\//_/g' | sed 's/\ /_/g') MYMODIFYFILENAME=$(echo "$MYFILENAME" | sed...

How to tar several files without containing their whole path in tar file

linux,bash,tar
Let's say I am in /tmp. I want to tar /tmp/aaa/123,/tmp/bbb/222. The command I use is: tar -vczf /tmp/my.tar.gz /tmp/aaa/123 /tmp/bbb/222. This command works fine. However, when I use tar -zxvf my.tar.gzto decompress the tar file, it gives me 2 file(let's say I copied my.tar.gz to a path called pwd...

git archive preserve time

git,unix,tar
I have some files in my git repo ... -rw-r--r-- 1 dimti dimti 11489 мар 2 21:54 wp-settings.php ... After execute command git archive --format=tar HEAD > repo.tar I fetch my files in tar-archive, but modify time is wrong: -rw-r--r-- 1 dimti dimti 11115 мар 5 21:55 wp-settings.php How to...

How to tar my C++ files on a linux server?

tar
I know this is a simple question, but I'm not sure why the tar process isn't working and I can't find a definitive answer on here. When doing the tar command: tar -cvjf<assign2comp.tar.bz2> <assign2.cpp header.cpp header.h> I'm getting the error, Missing name for redirect. Our professor shows this code as...

Exclude selected sub-directories while compressing

linux,git,ubuntu,compression,tar
Use this command to exclude sub-directories while compressing but it didn't work: tar -zcvf slice.tar.gz --exclude=slice/media* --exclude slice/images/doc/* slice It still compresses all the sub-directors inside media and doc. What am i doing wrong?...

Creating new tar file in current directory using single file

bash,tar
I'm writing a bash script that will check if a tar archive exists for a specific fileName.log, and if not, creating one with fileName.log. If a tar already exists, then I need to append fileName.log to it. I've never really worked with tar archives, aside from unzipping and unpacking .tar.gz...

is it possible to crate a tar of any file which will give different file name after untar

linux,tar
I have some files to tar for example abc.php_mtime_size now i want to TAR this file such that when I untar it will have a name "abc.php" so is there any way by which I can specify output file name as well while creating the TAR file.

Tar and save results directly to an SSH directory

linux,ssh,backup,tar
I have a server that I would like to make a tar backup of, but the server itself doesn't have enough disk space that is equal to the data it contains. Therefore, I would like to tar it directly to an ssh directory, such that it would dump the tar...

Tar --acl option is missing from 1.25 version

linux,tar
I am trying to upgrade the tar version on my system. Below is the current version. # tar --version tar (GNU tar) 1.17 If we execute tar --help Handling of file attributes: --acls Save the ACLs to the archive --atime-preserve don't change access times on dumped files We can see...

How to pipe tar.extractall from python

python,stdout,tar
I'm extracting a tarball using the tarfile module of python. I don't want the extracted files to be written on the disk, but rather get piped directly to another program, specifically bgzip. I'm also trying to use StringIO for that matter, but I get stuck even on that stage -...

tar archive without metadata

linux,md5,tar,file-attributes
Simple example: tar cf <archive_name> <file_name> md5sum <archive_name> touch <file_name> tar cf <archive_name> <file_name> md5sum <archive_name> Results of md5sum are different. How to avoid this?...

creating a tarball, encrypt it on the fly and keeps tar messages in a log file

bash,shell,tar,gnupg,tee
On OSX I'm trying to create a tarball of a directory and on the fly encrypt it with gpg and keeps the output of the tar messages in a log file for later analysis. While the tar+gpg on the fly it's pretty easy tar zcvf - foo | gpg -e...