13

I am trying this command

tar cvpzf /TEMP_BACKUPS/backup.tgz --exclude=/proc --exclude=/lost+found  --exclude=/tmp --exclude=/TEMP_BACKUPS --exclude=/mnt --exclude=/sys / > /TEMP_BACKUPS/mylog.txt

and i am getting this error. I have tried twice

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

what do i need to do to make full backup

user1865341
  • 301
  • 1
  • 3
  • 7

3 Answers3

19

The fact is tar is successful, but prints out warning that those socket files are ignored

GNU tar actually provides an option to suppress warnings. You could ignore the "socket ignored" errors using the below command which avoids running a find command that could take a long time to complete.

tar --warning='no-file-ignored' -cpzf  backup_name.tar.gz  /folder_to_backup

This links has more details

Aravinth C
  • 191
  • 1
  • 4
18

Note that your tar command is completing successfully; it's just complaining about the socket entries. Tiffany is suggesting a mechanism for filtering out those particular error messages, although tar will still exit with an error code.

You could also feed a list of sockets to tar's -X option to have them excluded from the backup, e.g:

# 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

The advantage to this technique is that it makes tar's exit code more useful (that is, you can use the exit code to decide whether or not the backup completed successfully).

You could also shorten your command line by replacing your other --exclude options with a single -X (aka --exclude-from) and simply listing them in a file.

larsks
  • 43,623
  • 14
  • 121
  • 180
  • should I exclude `/run` as well? – ar2015 Apr 07 '16 at 11:30
  • the standard error of `find / -type s -print > /tmp/sockets-to-exclude` should be redirected somewhere (e.g., `/dev/null`), otherwise find complaints that some files created during the search do not exist. – Javier Arias Jul 12 '17 at 10:45
11

Sockets are zero level files that are used by daemon processes to communicate with each other. They are created and destroyed as necessary when the daemons start and stop. They can safely be ignored.

You can always get rid of them with tar <my_options> 2> >(grep -v 'socket ignored' >&2)

Tiffany Walker
  • 6,681
  • 14
  • 56
  • 82