how to back up files over the network with FreeBSD
December 15th, 2008

This procedure details how to copy data from a FreeBSD drive to a network drive. The network drive is assumed to be available with the SMB protocol. This means the procedure below can be used to copy files to a Windows server, or to a unix server running Samba.

The procedure is NOT for backing up system files, it is for backing up data directories.

  1. ensure you're logged in as root on the FreeBSD machine (the machine to copy files FROM)
  2. ensure the mountpoint (used below) is created before attempting the mount command
  3. mount the remote volume:
    mount_smbfs //ms-windows-user-id@MS-SERVER-NAME/MS-Windows-Share /mnt/mountpoint
    mount_smbfs //trevor@bigserver/shared /mnt/shared
  4. enter the password to the share if prompted
  5. ensure you can see the share when you run the df command
  6. Now to copy the data. If you're brave, you can copy all the data at once, however this is not recommended as it will stress your hardware. It's recommended to copy one directory at a time, leaving some time between directories. This will allow your hardware time to cool. It will also minimise the damage, if you copy the wrong thing to the wrong place. Use this command to copy the /example/source directory, and all its subdirectories, from the old drive to the new drive:
    cp -Rpv /source_device/directory/to/copy /target_device/directory/to/copy/to
    cp -Rpv /usr/data/example/source /mnt/shared/example

    This will create the "source" directory in the "example" directory on the remote volume. The "example" directory must already exist.

  7. repeat the above command for each directory to copy
  8. (optional) test the copied data somehow, if there's a large ZIP file this can be tested for errors
  9. unmount the remote volume:
    umount /mnt/mountpoint