Article ID: kb00201Last Modified: 13-Jul-2025

Mounting/Unmounting Network Shares Before or After Backup

This article cantaons information for computers running Linux and macOS.

While most of the information in this article is valid regardless of which version of MSP360 (formerly CloudBerry) Backup is used, the most important part (the -preAction and -postAction options) are only available since Backup for Linux?macOS v 2.9

Linux

The case described in this article is:

  • There is a domain shared folder that serves as a file share
  • This shared folder is used for backup (whether as the source or the destination, does not matter)
  • The backup will be performed by Backup for Linux

Also, the commands syntax may differ for various Linux distributions and/or SMB configurations (in case it's a Linux-based NAS device). This article is based on Ubuntu 18 and a Windows 2012R2 domain network share.

So, let's start.

  1. Change the backup plan ownership to the user who is allowed to mount network shares:
sudo chown root:root /opt/local/CloudBerry\ Backup/etc/plans/*

Note: If you choose to use another user:group, make sure to set the same user:group in step 2

  1. Create a file with the access credentials to the network share:
echo "username=USERNAME" >  /path/to/credentials-file
echo "password=PASSWORD" >> /path/to/credentials-file
echo "domain=DOMAIN" >> /path/to/credentials-file

Note: No need to escape any special symbols in your password with the backslash

Note: The third line is not required for a workgroup shared folder or a Linux-based NAS device

  1. Assign the desirable access permission to the credentials file
chown root:root /path/to/credentials-file
chmod 600 /path/to/credentials-file
  1. Add the mount point to /etc/fstab
sudo echo "//SHARE-DOMAIN-NAME/SHARED-FOLDER-PATH /mnt/SHARE cifs credentials=/path/to/credentials-file,iocharset=utf8,sec=ntlmssp 0 0" >> /etc/fstab
  1. Create a script to mount the share
echo "#!/bin/bash" > /path/to/script-mount.sh
echo "mount /mnt/SHARE" >> /path/to/script-mount.sh
echo "exit 0" >> /path/to/script-mount.sh
chmod 711 /path/to/script-mount.sh
  1. Create a script to unmount the share
echo "#!/bin/bash" > /path/to/script-umount.sh
echo "umount /mnt/SHARE" >> /path/to/script-umount.sh
echo "exit 0" >> /path/to/script-umount.sh
chmod 711 /path/to/script-umount.sh

Pre-/Post actions

Set the two scripts as the pre-backup action and the post-backup action.

/opt/local/CloudBerry\ Backup/bin/cbb editBackupPlan -n "Backup plan name goes here" -preAction yes -preActionPath "/path/to/script-mount.sh" -postAction yes -postActionPath "/path/to/script-umount.sh -postActionRunAnyway yes"

This can be also done in the GUI or in the Web Interface, on the Pre-/Post actions step of the backup plan wizard.

macOS

Mount Network Share

You can mount a network share using Finder or Terminal.

Option 1: Using Finder (GUI)

  1. Open Finder.

  2. Press Cmd + K or go to Go > Connect to Server.

  3. In the Server Address field, enter:

smb://SERVER_ADDRESS/ShareName

Example:

smb://192.168.1.100/shared-folder
  1. Click Connect. Enter your username and password if prompted.

Mounted shares appear under Locations in Finder and on the Desktop (if enabled)

Option 2: Using Terminal

  1. Create a mount point:
mkdir ~/mnt/myshare
  1. Mount the share. You will be prompted for the password.
mount_smbfs //username@server_address/sharename ~/mnt/myshare

Example:

mount_smbfs //user@192.111.1.100/shared-folder ~/mnt/myshare

Unmount Network Share

You can unmount a network share using Finder or Terminal.

Option 1: Finder

  1. Right-click the mounted network drive on the Desktop or in Finder sidebar.
  2. Select Eject.

Option 2: Terminal

umount ~/mnt/myshare

Pre-/Post actions

Set the mount and unmount bash scripts as the pre-backup action and the post-backup action on the Pre-/Post actions step of the backup plan wizard - the procedure is quite obvious so no additional description here.

Contact Us

https://git.cloudberrylab.com/egor.m/doc-help-kb.git
Production