我正在尝试这个命令
tar cvpzf /TEMP_BACKUPS/backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/tmp --exclude=/TEMP_BACKUPS --exclude=/mnt --exclude=/sys / > /TEMP_BACKUPS/mylog.txt
我遇到了这个错误。我尝试了两次
tar: Removing leading `/' from member names
tar: /dev/log: socket ignored
tar: Removing leading `/' from hard link targets
tar: /selinux/policy: Cannot open: Invalid argument
tar: /var/spool/postfix/public/flush: socket ignored
tar: /var/spool/postfix/public/cleanup: socket ignored
tar: /var/spool/postfix/public/showq: socket ignored
tar: /var/spool/postfix/private/defer: socket ignored
tar: /var/spool/postfix/private/virtual: socket ignored
tar: /var/spool/postfix/private/proxywrite: socket ignored
tar: /var/spool/postfix/private/verify: socket ignored
tar: /var/spool/postfix/private/anvil: socket ignored
tar: /var/spool/postfix/private/lmtp: socket ignored
tar: /var/spool/postfix/private/bounce: socket ignored
tar: /var/spool/postfix/private/relay: socket ignored
tar: /var/spool/postfix/private/scache: socket ignored
tar: /var/spool/postfix/private/retry: socket ignored
tar: /var/spool/postfix/private/error: socket ignored
tar: /var/spool/postfix/private/rewrite: socket ignored
tar: /var/spool/postfix/private/tlsmgr: socket ignored
tar: /var/spool/postfix/private/local: socket ignored
tar: /var/spool/postfix/private/discard: socket ignored
tar: /var/spool/postfix/private/trace: socket ignored
tar: /var/spool/postfix/private/smtp: socket ignored
tar: /var/spool/postfix/private/proxymap: socket ignored
tar: /var/lib/mysql/mysql.sock: socket ignored
tar: /var/www/html/run/wsgi.1458.0.1.sock: socket ignored
tar: /var/www/html/run/wsgi.4861.1.1.sock: socket ignored
tar: /var/www/html/run/wsgi.1178.0.1.sock: socket ignored
tar: /var/www/html/run/wsgi.1179.0.1.sock: socket ignored
tar: /var/run/dbus/system_bus_socket: socket ignored
tar: /var/run/abrt/abrt.socket: socket ignored
tar: /var/run/rpcbind.sock: socket ignored
tar: /var/run/portreserve/socket: socket ignored
tar: /var/run/nscd/socket: socket ignored
tar: Exiting with failure status due to previous errors
我需要做什么才能进行完整备份
答案1
请注意,您的tar
命令已成功完成;它只是抱怨套接字条目。蒂芙尼建议采用一种机制来过滤掉这些特定的错误消息,尽管tar
仍然会以错误代码退出。
您还可以将套接字列表提供给tar
选项-X
以将它们排除在备份之外,例如:
# find / -type s -print > /tmp/sockets-to-exclude
# tar cvpzf /TEMP_BACKUPS/backup.tgz -X /tmp/sockets-to-exclude \
--exclude=/proc --exclude=/lost+found --exclude=/tmp \
--exclude=/TEMP_BACKUPS --exclude=/mnt --exclude=/sys / > /TEMP_BACKUPS/mylog.txt
这种技术的优点是它使tar
退出代码更有用(也就是说,您可以使用退出代码来决定备份是否成功完成)。
--exclude
您还可以通过将其他选项替换为单个选项-X
(又名--exclude-from
)并简单地将它们列在文件中来缩短命令行。
答案2
事实是 tar 成功了,但打印出警告说这些套接字文件被忽略
GNU tar 实际上提供了一个抑制警告的选项。您可以使用以下命令忽略“套接字忽略”错误,从而避免运行可能需要很长时间才能完成的 find 命令。
tar --warning='no-file-ignored' -cpzf backup_name.tar.gz /folder_to_backup
答案3
套接字是守护进程用来相互通信的零级文件。它们在守护进程启动和停止时根据需要创建和销毁。可以安全地忽略它们。
你可以随时用以下方法摆脱它们tar <my_options> 2> >(grep -v 'socket ignored' >&2)