我有一个文件夹结构,我正在备份被修改的文件下面是文件夹结构
/home/aaditya/customer/jiva/foo/bar/File1.txt
使用以下命令我想备份文件1.txt文件
cd /home/aaditya/customer/jiva/foo/bar
tar -zcvf archive_backup_folder.tar.gz File1.txt
但我的问题陈述是,当我解压缩 tar archive_backup_folder时,File1.txt 应该在里面,customer/jiva/foo/bar/File1.txt
不仅File1.txt
谁能帮我怎么做。
只需执行以下操作:
cd /home/aaditya/
tar -zcvf archive_backup_folder.tar.gz customer/jiva/foo/bar/File1.txt
也就是说,在存档中包含路径结构。
你可以尝试这样的事情
TIME=`date +%b-%d-%y`
FILENAME=backup-$TIME.tar.gz
SRCDIR= directory or file that has to be backed up
DESDIR= place where you need to store it
tar -cpzf $DESDIR/$FILENAME $SRCDIR
cd /home/aaditya/
find customer -mtime -1 -exec tar -rvf test.tar {} ;
"find"命令将在1天内找出所有修改的文件,并为每个文件运行"tar -rvf test.tar the_file"将其添加到test中.tar(在运行"find"命令之前,您希望"rm -f test.tar"