Skip to content

Backing Up a Linux server in the DMZ to a Windows Share

This script connects to a remote Linux server and backs it up to a file share on a Windows server. Note, that because the version of smbfs used does not support files larger than 2GB the backup is split into multiple files. Later versions of smbfs don’t have this limitation.

 #!/bin/sh
 RemHost=lnx-server
 TarFile="/windows-server/lnx-server-backup/lnx-server.tar.gz."
 # Mount the drive to backup to
 mount -t smbfs -o username="domain\\account" \
   -o password="'password'" \
   '//windows-server/lnx-server-backup$' /mnt/lnx-server-backup
 
ssh $RemHost "cd / ; tar --gzip -cf - . ; /root/logs/backup.log" \
 | split -b 2000000000 - $TarFile
 sleep 10
 
umount /mnt/lnx-server-backup

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*