tar

linux解压 tar命令

佐手、 提交于 2019-12-22 01:59:45
tar [-cxtzjvfpPN] 文件与目录 .... 参数: -c :建立一个压缩文件的参数指令(create 的意思); -x :解开一个压缩文件的参数指令! -t :查看 tarfile 里面的文件! 特别注意,在参数的下达中, c/x/t 仅能存在一个!不可同时存在! 因为不可能同时压缩与解压缩。 -z :是否同时具有 gzip 的属性?亦即是否需要用 gzip 压缩? -j :是否同时具有 bzip2 的属性?亦即是否需要用 bzip2 压缩? -v :压缩的过程中显示文件!这个常用,但不建议用在背景执行过程! -f :使用档名,请留意,在 f 之后要立即接档名喔!不要再加参数!    例如使用『 tar -zcvfP tfile sfile』就是错误的写法,要写成    『 tar -zcvPf tfile sfile』才对喔! -p :使用原文件的原来属性(属性不会依据使用者而变) -P :可以使用绝对路径来压缩! -N :比后面接的日期(yyyy/mm/dd)还要新的才会被打包进新建的文件中! --exclude FILE:在压缩的过程中,不要将 FILE 打包! 范例: 范例一:将整个 /etc 目录下的文件全部打包成为 /tmp/etc.tar [root@linux ~]# tar -cvf /tmp/etc.tar /etc<==仅打包,不压缩!

Docker volume: backup

∥☆過路亽.° 提交于 2019-12-21 20:33:03
问题 I have created a volume container. And a container which mounts to en from the volume container. Volume container: docker run -d --name nexus-data nexus:1.0 echo "data-only container for Nexus" My Nexus container: docker run -d -p 8443:8443 -p 8081:8081 --name nexus --restart=always --volumes-from nexus-data nexus:1.0 So this is working fine. I'm able to delete and recreate my nexus-container without losing data. The volume container (which isn't in running state) is saving the data. But the

How to write a large amount of data in a tarfile in python without using temporary file

这一生的挚爱 提交于 2019-12-21 20:32:53
问题 I've wrote a small cryptographic module in python whose task is to cipher a file and put the result in a tarfile. The original file to encrypt can be quit large, but that's not a problem because my program only need to work with a small block of data at a time, that can be encrypted on the fly and stored. I'm looking for a way to avoid doing it in two passes, first writing all the data in a temporary file then inserting result in a tarfile. Basically I do the following (where generator

Python import library from tar.gz?

☆樱花仙子☆ 提交于 2019-12-21 17:21:54
问题 I am working on a box which I don't have root access. However, there is a folder /share which would be accessed for everyone to read and write. I want to figure out a way to put python libraries so that everyone could access and use them. I figured out that I can put the egg file in the /share/pythonLib folder and in the python script. import sys sys.path.append("/share/pythonLib/foo.egg") import foo and it would work for everyone, however, I am not sure every library has egg version. For

How can I efficiently move many files to a new server?

谁说胖子不能爱 提交于 2019-12-21 17:19:04
问题 I'm switching hosting providers and need to transfer millions of uploaded files to a new server. All of the files are in the same directory. Yes. You read that correctly. ;) In the past I've done this: Zip all of the files from the source server scp the zip to the new server Unzip Move directory to appropriate location for whatever reason my zips from step 1 always bring the path along with them and require me to mv. The last time I did this it took about 4-5 days to complete and that was

Ruby streaming tar/gz

老子叫甜甜 提交于 2019-12-21 14:41:48
问题 Basically I want to stream data from memory into a tar/gz format (possibly multiple files into the tar, but it should NEVER TOUCH THE HARDDRIVE, only streaming!), then stream them somewhere else (an HTTP request body in my case). Anyone know of an existing library that can do this? Is there something in Rails? libarchive-ruby is only a C wrapper and seems like it would be very platform-dependent (the docs want you to compile as an installation step?!). SOLUTION: require 'zlib' require

How can I tar files larger than physical memory using Perl's Archive::Tar?

北城余情 提交于 2019-12-21 12:25:40
问题 I'm using Perl's Archive::Tar module. Problem with it is it pulls everything on to the memory and the does archiving and then writes on to the file system so there is limitation on the maximum file size that can be archived. Most of the times it says out of memory. In case of GNU tar, it takes chunk of file, archives it and writes it on to the memory so it can handle files of any size. How can I do that using Perl's Archive::Tar module. 回答1: It looks like there is a different module that

Linux 重定向 管理组和用户 tar备份和恢复 crone计划任务(DAY4牛)

南笙酒味 提交于 2019-12-21 12:23:51
重定向操作:将前面命令的输出,作为文本文件内容写入到文件中 >:覆盖重定向 >>:追加重定向 [root@A ~]# cat --help > /opt/cat.txt [root@A ~]# cat /opt/cat.txt [root@A ~]# hostname [root@A ~]# hostname > /opt/cat.txt [root@A ~]# cat /opt/cat.txt [root@A ~]# hostname >> /opt/cat.txt [root@A ~]# cat /opt/cat.txt [root@A ~]# ifconfig >> /opt/cat.txt [root@A ~]# cat /opt/cat.txt [root@A ~]# echo hello [root@A ~]# echo 123456 [root@A ~]# echo 123456 > /opt/cat.txt [root@A ~]# cat /opt/cat.txt [root@A ~]# echo haha >> /opt/cat.txt [root@A ~]# cat /opt/cat.txt [root@A ~]# echo linux >> /opt/cat.txt [root@A ~]# cat /opt/cat.txt ##################

python tar file how to extract file into stream

筅森魡賤 提交于 2019-12-21 10:49:58
问题 I am trying to extract a zipped folder but instead of directly using .extractall() , I want to extract the file into stream so that I can handle the stream myself. Is it possible to do it using tarfile ? Or is there any suggestions? 回答1: You can obtain each file from a tar file as a python file object using the .extractfile() method. Loop over the tarfile.TarFile() instance to list all entries: import tarfile with tarfile.open(path) as tf: for entry in tf: # list each entry one by one fileobj

python tar file how to extract file into stream

坚强是说给别人听的谎言 提交于 2019-12-21 10:49:01
问题 I am trying to extract a zipped folder but instead of directly using .extractall() , I want to extract the file into stream so that I can handle the stream myself. Is it possible to do it using tarfile ? Or is there any suggestions? 回答1: You can obtain each file from a tar file as a python file object using the .extractfile() method. Loop over the tarfile.TarFile() instance to list all entries: import tarfile with tarfile.open(path) as tf: for entry in tf: # list each entry one by one fileobj