【问题标题】:Incremental backup tar error增量备份 tar 错误
【发布时间】:2013-08-21 23:55:49
【问题描述】:

我正在做一个备份系统。

我有两台服务器:主服务器发送数据到备份服务器,然后,备份服务器压缩数据。为了节省磁盘使用量,我只需压缩已更改的文件,这要归功于存储上次备份时间的flag-file

有时它可以正常工作,但有时我的脚本退出时出现error 123此错误来自xargs

描述是: 123 if any invocation of the command exited with status 1-125

所以我发布的command 是:

find /home/* -name "<em>.</em>" -not -path "/home/*/www/cache/*" -not -path "/home/*/www/cc/cache/*" -not -path "/home/*/www/ot/cache/*" -not -path "/home/backups/*" -newer /var/backups/data/flagfile -print0 | xargs -0 -r tar -czvf /home/backups/incremental/H14/backup.tar.gz

当我这样做时: find /home/* -name "*.*" -not -path "/home/*/www/cache/*" -not -path "/home/*/www/cc/cache/*" -not -path "/home/*/www/ot/cache/*" -not -path "/home/backups/*" -newer /var/backups/data/flagfile -print0

它会像预期的那样返回一个文件列表。

感谢您的帮助!

【问题讨论】:

    标签: linux command-line backup tar


    【解决方案1】:

    首先将文件列表重定向到文本文件可能是个好主意,称之为files.txt

    find /home/* -name "." 
        -not -path "/home/*/www/cache/*" 
        -not -path "/home/*/www/cc/cache/*" 
        -not -path "/home/*/www/ot/cache/*"
        -not -path "/home/backups/*" 
    -newer /var/backups/data/flagfile -print0 > files.txt
    
    tar -czvf /home/backups/incremental/H14/backup.tar.gz ... 
    

    任何用户都可以通过上传将一些非常奇怪的文件名写入您的系统 到他们的网站。

    xargs 崩溃时,使用 hexviewer 查看文件并检查非 ascii 字符;) 还有你使用的是哪个版本的 xargs...

    【讨论】:

    • 感谢您的回答。所以 xargs 的版本是 4.4.2 我已经按照你说的做了。但是我没有使用 xargs ,而是启动了这个命令:tar -czf archive.tar -I list.txt
    • 我希望它有效,关键是通过查看 files.txt 来检查错误的文件名。这是 xargs 手册页的链接,link,尤其是 bug 部分。看起来也不错。
    • 另一个问题是文件可以在运行过程中被删除。
    【解决方案2】:

    我用下面的代码解决了这个问题:

    find /home/* -name "." -not -path "/home/*/www/cache/*" -newer /var/backups/data/flagfile -print0 > files.txt

    然后是 tar 命令:

    tar czvf /home/backups/incremental/H14/backup.tar.gz --files-from files.txt --quoting-style=shell

    --quoting-style=shell 转义特殊字符,因此 tar 不会退出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-06
      • 2018-12-29
      • 2017-05-05
      • 2014-02-24
      • 1970-01-01
      • 1970-01-01
      • 2013-06-18
      相关资源
      最近更新 更多