smbclient may be used to create
tar compatible backups of all the
files on an SMB/CIFS share. The secondary tar flags that can
be
given to this option are :•
c - Create a tar file on UNIX. Must be followed by the name
of a tar file, tape device or "-" for standard output. If
using standard output you must turn the log level to its
lowest value -d0 to avoid corrupting your tar file. This
flag is mutually exclusive with the x flag.
•
x - Extract (restore) a local tar file back to a share.
Unless the -D option is given, the tar files will be
restored from the top level of the share. Must be followed
by the name of the tar file, device or "-" for standard
input. Mutually exclusive with the c flag. Restored files
have their creation times (mtime) set to the date saved in
the tar file. Directories currently do not get their
creation dates restored properly.
•
I - Include files and directories. Is the default behavior
when filenames are specified above. Causes files to be
included in an extract or create (and therefore everything
else to be excluded). See example below. Filename globbing
works in one of two ways. See r below.
•
X - Exclude files and directories. Causes files to be
excluded from an extract or create. See example below.
Filename globbing works in one of two ways now. See r below.
•
F - File containing a list of files and directories. The F
causes the name following the tarfile to create to be read
as a filename that contains a list of files and directories
to be included in an extract or create (and therefore
everything else to be excluded). See example below. Filename
globbing works in one of two ways. See r below.
•
b - Blocksize. Must be followed by a valid (greater than
zero) blocksize. Causes tar file to be written out in
blocksize*TBLOCK (usually 512 byte) blocks.
•
g - Incremental. Only back up files that have the archive
bit set. Useful only with the c flag.
•
q - Quiet. Keeps tar from printing diagnostics as it works.
This is the same as tarmode quiet.
•
r - Regular expression include or exclude. Uses regular
expression matching for excluding or excluding files if
compiled with HAVE_REGEX_H. However this mode can be very
slow. If not compiled with HAVE_REGEX_H, does a limited
wildcard match on '*' and '?'.
•
N - Newer than. Must be followed by the name of a file whose
date is compared against files found on the share during a
create. Only files newer than the file specified are backed
up to the tar file. Useful only with the c flag.
•
a - Set archive bit. Causes the archive bit to be reset when
a file is backed up. Useful with the g and c flags.
Tar Long File Names
smbclient's tar option now supports long file names both
on backup and restore. However, the full path name of the
file must be less than 1024 bytes. Also, when a tar archive
is created, smbclient's tar option places all files in the
archive with relative names, not absolute names.
Tar Filenames
All file names can be given as DOS path names (with '\'
as the component separator) or as UNIX path names (with '/'
as the component separator).
Examples
Restore from tar file backup.tar into myshare on mypc (no
password on share).
smbclient //mypc/yshare "" -N -Tx backup.tar
Restore everything except users/docs
smbclient //mypc/myshare "" -N -TXx backup.tar users/docs
Create a tar file of the files beneath
users/docs.
smbclient //mypc/myshare "" -N -Tc backup.tar users/docs
Create the same tar file as above, but now use a DOS path
name.
smbclient //mypc/myshare "" -N -tc backup.tar users\docs
Create a tar file of the files listed in the file tarlist.
smbclient //mypc/myshare "" -N -TcF backup.tar tarlist
Create a tar file of all the files and directories in the
share.
smbclient //mypc/myshare "" -N -Tc backup.tar * |