tar

Compress on the fly a directory in tar.gz format using PHP

China☆狼群 提交于 2019-12-10 05:13:35
问题 I want to compress (on the fly) a directory in tar.gz format using PHP. I know it can be done with exec or using this code (using ZIP format) but my host doesn't support exec and hasn't installed the zip extension of PHP. After searching the internet I came across this PHP code: <?php // Computes the unsigned Checksum of a file’s header // to try to ensure valid file // PRIVATE ACCESS FUNCTION function __computeUnsignedChecksum($bytestring) { for($i=0; $i<512; $i++) $unsigned_chksum += ord(

Postgres Tutorial: pg_restore: [archiver] input file does not appear to be a valid archive

一笑奈何 提交于 2019-12-10 03:11:15
问题 I'm working through the Postgres DVD tutorial and am running into issues importing their sample database. Running pg_restore -U postgres -d dvdrental ~[filepath]/dvd-database.tar.gz gives me pg_restore: [archiver] input file does not appear to be a valid archive . My process so far has been the following: Download the dvdrental.zip file Extract it to a .tar using tar czf dvd-database.tar.gz dvdrental.zip (I've also tried extracting the zip to a folder first with the same result, as well as

How do I extract only the file of a .tar.gz member?

落花浮王杯 提交于 2019-12-09 20:19:54
问题 My goal is to unpack a .tar.gz file and not its sub-directories leading up to the file. My code is based off this question except instead of unpacking a .zip I am unpacking a .tar.gz file. I am asking this question because the error I'm getting is very vague and doesn't identify the problem in my code: import os import shutil import tarfile with tarfile.open('RTLog_20150425T152948.gz', 'r:gz') as tar: for member in tar.getmembers(): filename = os.path.basename(member.name) if not filename:

linux系统备份与恢复

半城伤御伤魂 提交于 2019-12-09 18:56:15
-------------------------------------------------------------- Linux Backup And Recovery //Backup: $ sudo su # cd / gzip压缩 # tar cvpzf backup.tgz --exclude=/proc --exclude=/sys --exclude=/lost+found --exclude=/backup.tgz \ --exclude=/mnt --exclude=/media --exclude=/home / Bzip2压缩: # tar cvpjf backup.tar.bz2 –exclude=/proc –exclude=/lost+found –exclude=/backup.tar.bz2 –exclude=/mnt –exclude=/sys / 在档案文件名"backup.gz"和要备份的目录名"/"之间给出了备份时必须排除在外的目录, 有些目录是无用的,例如"/proc","/lost+ found","/sys",当然,"backup.gz"这个档案文 件本身必须排除在外,否则你可能会得到一些超出常理的结果.如果不把"/mnt"排 除在外, 那么挂载在"/mnt"上的其它分区也会被备份.另外需要确认一下"/media

Encoding errors when compressing files with Apache Commons Compression on Linux

百般思念 提交于 2019-12-09 18:49:48
问题 I am compressing files using the Apache Commons API Compression. Windows 7 works fine, but in Linux (ubuntu 10.10 - UTF8), characters in file names and folder names, such as "º", for example, are replaced by "?". Is there any parameter I should pass to the API when compact, or when uncompressing tar? I'am using tar.gz format, following the API examples. The files I'm trying compress, are created in windows... is there any trouble? The code: public class TarGzTest { public static void

Linux命令(全)

戏子无情 提交于 2019-12-09 15:28:32
linux系统命令的命令选项可以组合使用,比如我们常用的 rm -rf * (哈哈,这是玩笑话,这条命令虽然不流行了,但谨慎使用,否则后果自负) 一、文件/文件夹管理(Linux基础命令) 1. 查看目录 命令 用途 ls 查看当前目录所有文件(不含隐藏文件) tree 目录名 以树状方式显示目录信息(含目录下所有文件) pwd 查看当前目录路径 ls -a 查看当前目录所有文件(含隐藏文件) ls -l 查看当前目录下文件的详情信息(不含隐藏文件) ls -h 以字节的方式显示文件大小 ls -al 查看当前目录下文件的详情信息(含隐藏文件) 2. 切换目录 命令 用途 cd 目录 切换到指定目录(必须是在当前目录下的文件) cd ~ 切换到当前用户的主目录 cd … 切换到上一级目录 cd . 切换到当前目录 cd - 切换到上一次目录 3. 创建、删除目录及文件 命令 用途 touch 文件名 创建指定文件 mkdir 目录名 创建目录(文件夹) mkdir -p 以层级的关系创建文件夹 rm 文件或目录名 删除指定文件或目录 rm -i 交互式提示 rm -r 删除文件下及文件下所有文件 rm -f 强制删除,忽略不存在的文件,不会提示 rm -d 删除空目录 rmdir 目录名 删除空目录 注意点:rm可以结合 -ir、-rf、-fd使用,但-i不能结合-f使用。

How to create flat tar archive

隐身守侯 提交于 2019-12-09 15:15:57
问题 my tree command returns tmp `-- t `-- e |-- 23.ps `-- s |-- adsf.ps `-- t `-- dupa.ps How can I create archive ps.tar.gz in tmp directory with following structure: tmp |-- ps.tar.gz | |-- 23.ps | |-- adsf.ps | `-- dupa.ps `-- t `-- e |-- 23.ps `-- s |-- adsf.ps `-- t `-- dupa.ps ? 回答1: outfile=$(pwd)/ps.tar;find . -type f | while read file; do tar rf $outfile -C $(dirname $file) $(basename $file) done gzip $outfile 回答2: for GNU tar you can use the --xform argument. It takes a sed expression

Ubuntu 14.04---Nginx+uWsgi+Django+Python+MongoDB+m

无人久伴 提交于 2019-12-09 13:13:57
安装步骤:(假设root用户是dev) //----------------------------------------------------------------- 1a. 安装Python (Ubuntu 12.04 default already install Python 2.7.3) # cd /home/dev/Download # wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz # tar xvfz Python-2.7.3.tgz # cd Python-2.7.3 #./configure # make # sudo make install 1b. 安装Python的包管理 setuptools 安装 # cd /home/dev/Download # wget http://peak.telecommunity.com/dist/ez_setup.py # sudo python ez_setup.py 1c. 安装Python的包管理pip安装(需要先安装setuptools) # cd /home/dev/Download # wget http://python-distribute.org/distribute_setup.py # sudo python

linux命令大全

北城余情 提交于 2019-12-09 13:00:39
Linux常用命令大全(非常全!!!) 最近都在和Linux打交道,感觉还不错。我觉得Linux相比windows比较麻烦的就是很多东西都要用命令来控制,当然,这也是很多人喜欢linux的原因,比较短小但却功能强大。我将我了解到的命令列举一下,仅供大家参考: 系统信息 arch 显示机器的处理器架构 uname -m 显示机器的处理器架构 uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS / DMI) hdparm -i /dev/hda 罗列一个磁盘的架构特性 hdparm -tT /dev/sda 在磁盘上执行测试性读取操作 cat /proc/cpuinfo 显示CPU info的信息 cat /proc/interrupts 显示中断 cat /proc/meminfo 校验内存使用 cat /proc/swaps 显示哪些swap被使用 cat /proc/version 显示内核的版本 cat /proc/net/dev 显示网络适配器及统计 cat /proc/mounts 显示已加载的文件系统 lspci -tv 罗列 PCI 设备 lsusb -tv 显示 USB 设备 date 显示系统日期 cal 2007 显示2007年的日历表 date 041217002007.00 设置日期和时间 - 月日时分年

Extract only a single directory from tar

岁酱吖の 提交于 2019-12-09 09:46:53
问题 I am working on a project in python in which I need to extract only a subfolder of tar archive not all the files. I tried to use tar = tarfile.open(tarfile) tar.extract("dirname", targetdir) But this does not work, it does not extract the given subdirectory also no exception is thrown. I am a beginner in python. Also if the above function doesn't work for directories whats the difference between this command and tar.extractfile() ? 回答1: Building on the second example from the tarfile module