Linux / sh:7zip如何通过保留完整路径进行压缩?

时间:2017-03-17 03:31:46

标签: shell path 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”文件夹“防火墙”

如何将此更改为完整路径,例如 / etc / firewall /

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。

  1. 我们需要使用 p7zip 16.02与 -spf2 选项 - https://sourceforge.net/projects/p7zip/files/p7zip/16.02/
  2. 将二进制文件复制到 / usr / bin / p7zip
  3. chmod find" / 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}" -ir@"${BACKUP_DIR}/tmp_config_folders.lst" -i@"${BACKUP_DIR}/tmp_config_files.lst" -xr!thumbs.db -xr!@eaDir -xr!@tmp -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;