2017-03-17 110 views
0

我使用:Linux/sh:7zip如何在保留完整路徑的情況下進行壓縮?

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 
p7zip Version 9.20 (locale=C,Utf16=off,HugeFiles=on,4 CPUs) 

#!/bin/sh 

/usr/syno/bin/7z a "/volume1/backup/backup_configfiles.7z" "/etc/firewall/" -t7z -m0=lzma2 -ms=off -mfb=64 -md=32m -mhe -mmt -mx9 -v100m -p"a" 

在的7z文件,我有文件夾「防火牆」只是沒「等」文件夾。

如何將其更改爲完整路徑,如/etc/firewall/

回答

0

我找到了解決辦法。

  1. 我們需要使用的p7zip 16.02與-spf2選項 - https://sourceforge.net/projects/p7zip/files/p7zip/16.02/
  2. 複製二進制文件的/ usr/bin中/的p7zip
  3. 搭配chmod 發現「在/ usr/bin中/的p7zip /「-exec chmod 755 {} \;

    #!/bin/sh 
    TIMESTAMP=$(date +'%Y-%m-%d_%H-%M-%S') 
    

    files

    echo "/etc/*.secrets" > "${BACKUP_DIR}/tmp_config_files.lst" echo "/etc/shadow" >> "${BACKUP_DIR}/tmp_config_files.lst" echo "/var/packages/MariaDB/etc/my.cnf" >> "${BACKUP_DIR}/tmp_config_files.lst"

    folders

    echo "/etc/firewall/" > "${BACKUP_DIR}/tmp_config_folders.lst" echo "/etc/httpd/conf/" >> "${BACKUP_DIR}/tmp_config_folders.lst" echo "/etc/mysql/" >> "${BACKUP_DIR}/tmp_config_folders.lst"

    Compressing...

    /usr/bin/p7zip/7za a "${BACKUP_DIR}/backup_configfiles_${TIMESTAMP}.7z" -spf2 -t7z -m0=lzma2 -ms=off -mfb=64 -md=32m -mhe -mmt -mx9 -v${SPLIT_VOLUME} -p"${PASSWORD}" [email protected]"${BACKUP_DIR}/tmp_config_folders.lst" [email protected]"${BACKUP_DIR}/tmp_config_files.lst" -xr!thumbs.db [email protected] [email protected] -xr!#recycle -xr!lost+found -xr!.DS_Store >> "$LOG_FILE2" 2>&1;

    Verifying files...

    /usr/bin/p7zip/7za t "${BACKUP_DIR}/backup_configfiles_${TIMESTAMP}.7z.001" -t7z.split -p"${PASSWORD}" >> "$LOG_FILE2" 2>&1;
相關問題