smbtar
Backup/restore SMB shares to/from tar archives
SYNOPSIS
smbtar options
PARAMETERS
{-t | -c | -x}
Mode of operation: -t (list), -c (create), -x (extract).
-s service
SMB/CIFS service (share name) to access. The format is typically \\server\share.
-p password
Password to use for authentication.
-u username
Username to use for authentication.
-g
Retrieve and restore group ownership information.
-z
Compress the archive using gzip.
-j
Compress the archive using bzip2.
-T tarfile
Name of the tar archive file.
-b blocksize
Block size for tar operations (in KB). Default is 20.
-i
Incremental backup. Requires server support.
-v
Verbose output.
-P
Preserve absolute paths.
-N hostname
NetBIOS name for the host (useful for resolving name resolution issues).
-o smbclient options
Additional options to pass directly to smbclient.
DESCRIPTION
The smbtar command is a utility for backing up and restoring files from SMB/CIFS network shares using the tar archiving format. It simplifies the process of creating backups of network shares accessible via the SMB protocol and restoring them. This is especially useful in environments where direct access to the underlying storage of the SMB share is not available or desirable. It leverages Samba's smbclient to interact with the SMB share, retrieves the files, and pipes them to tar for archiving. Similarly, during restoration, tar extracts the files, and smbclient writes them back to the target SMB share.
The command provides options for specifying the target SMB share, username, password, and other parameters needed for authentication. It also allows control over the tar process, such as specifying the archive file name, compression options, and whether to create a new archive or append to an existing one.
smbtar offers a convenient way to perform backups and restores of SMB shares, integrating seamlessly with the familiar tar archiving utility.
CAVEATS
smbtar relies heavily on the underlying functionality of both smbclient and tar. Ensure that these utilities are properly installed and configured.
Authentication issues with the SMB share can lead to errors. Verify that the provided username and password have the necessary permissions to access the share.
File attributes and permissions might not be perfectly preserved during the backup and restore process, especially when dealing with different operating systems or SMB server configurations.
EXAMPLES
Create a gzipped archive of an SMB share:smbtar -z -c -s //server/share -u user -p password -T backup.tar.gz
Restore an archive to an SMB share:smbtar -x -s //server/share -u user -p password -T backup.tar.gz
List the contents of an archive:smbtar -t -s //server/share -u user -p password -T backup.tar.gz
SECURITY
Storing passwords directly in scripts or command-line arguments is discouraged due to security risks. Consider using environment variables or other secure methods for storing and retrieving credentials.
HISTORY
smbtar was created to solve the need for backuping up SMB/CIFS shares without directly accessing the underlying storage. The command uses the tar format, which is a widely available and well-understood archive format, and integrate with smbclient.