Linux
使用 tar 備份整個 centos 時出錯
我正在嘗試這個命令
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
我需要做什麼才能進行完整備份
請注意,您的
tar
命令已成功完成;它只是在抱怨套接字條目。Tiffany 建議使用一種機制來過濾掉那些特定的錯誤消息,但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
(aka--exclude-from
) 並簡單地將它們列出在文件中來縮短命令行。