Automount external HDD over network with rsync or samba?
SlackwareThis Forum is for the discussion of Slackware Linux.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Automount external HDD over network with rsync or samba?
I want to backup files and folders to an external hard drive on a networked computer running Slackware 13.0. The external hard drive isn't always on or mounted, so how to make it available for backups in a way that won't glitch when the hard drive is off?
rsync sounds very convenient, but several computers on my network run Windows XP, so something more cross-platform would be great, such as Samba.
In a GUI, such as XFCE, the external HDD automounts by partition labels in Thunar file manager, but how can I get that result from a remote TUI or Windows XP?
This is /var/log/messages after mounting the drive in Thunar:
bash-3.1# tail /var/log/messages
Dec 31 07:46:58 tara kernel: pci 0000:01:00.0: PCI INT A -> Link[LNKA] -> GSI 11 (level, low) -> IRQ 11
Dec 31 07:46:58 tara kernel: [drm] Initialized r128 2.5.0 20030725 on minor 0
Dec 31 07:46:58 tara kernel: agpgart-intel 0000:00:00.0: AGP 2.0 bridge
Dec 31 07:46:58 tara kernel: agpgart-intel 0000:00:00.0: putting AGP V2 device into 1x mode
Dec 31 07:46:58 tara kernel: pci 0000:01:00.0: putting AGP V2 device into 1x mode
Dec 31 08:05:54 tara ntfs-3g: Version 2009.4.4 integrated FUSE 27
Dec 31 08:05:54 tara ntfs-3g: Mounted /dev/sda3 (Read-Write, label "BACKUPS", NTFS 3.1)
Dec 31 08:05:54 tara ntfs-3g: Cmdline options: rw,nosuid,nodev,uhelper=hal
Dec 31 08:05:54 tara ntfs-3g: Mount options: rw,nosuid,nodev,uhelper=hal,silent,allow_other,nonempty,relatime,fsname=/dev/sda3,blkdev,blksize=4096
Dec 31 08:05:54 tara hald: mounted /dev/sda3 on behalf of uid 1000
The external HDD doesn't have an entry in /etc/fstab.
I use an external disk for my backups. My office machine is my primary system that concerns me the most for backups and that is where I install the drive. I use a SATA drive and removable drive bay tray. A USB drive would accomplish the same thing.
I use rsnapshot as my backup foundation. Rsnapshot uses rsync. In my rsnapshot config files I have rsnapshot look for other computers on my home LAN. If the machines are available then files are backed up. If not, then rsnapshot notes this in the logs and performs a backup of those systems by copying the previous backup.
I use cron to run rsnapshot. I backup config files and user directories every three hours to a second drive installed in my office machine. The process is manual for my weekly backups, which requires that external drive. The system is not perfect because I don't have all of these machines powered on 24/7, but is good enough for me.
I don't have any physical Windows machines connected here 24/7, but I do have two older systems configured to run Windows in a dual boot manner. Primarily I run Windows in virtual machines, one of which being important enough to perform backups. I don't backup the physical Windows machines, but by using Samba, rsnapshot functions the same for my those machines as I just described.
For my virtual Windows machine, I perform a backup of important files to my local hard drive through Samba. The virtual Windows machine does not know any better and thinks the Samba mounted local file system is a local drive. When I perform my manual weekly backup with my external drive, those backup files get copied to the external drive because the backup files merely are part of the entire local drive file system.
If you want to learn more about this process and grab the scripts, then perhaps the following will help:
I have WindowsXP machines on a network with a server running Slackware 13 and an external usb drive.
The Windows directories to be be backed up are mounted as Samba shares on the server.
I then have a small script that is run as a cron job to perform the regularly scheduled backup.
This script just mounts the external usb drive, performs an rsync backup and the unmounts the external usb drive. The script is run as root so that mount.ntfs-3g can mount the external usb drive that is formatted with NTFS.
# Copy files in project directories
# to external usb harddrive
# Intended to be run as a cron job by root
mount /mnt/extusbhd ; \
rsync -aub --backup-dir=/mnt/extusbhd/backuptemp <Samba mount> /mnt/extusbhd/Projects/ ; \
The above script could (and should!) be modified to test that the external drive IS mounted before proceeding with the backup. (Probably as simple as 'if $(mount /mnt/extusbhd); then' ).
I have an entry in /etc/fstab that uses 'UUID=xxx' to specify the external drive so that the device is always mounted at the same point in the file system.
# External usb harddrive for data backups writable by user with uid=1002
UUID=D86447246447052A /mnt/extusbhd ntfs-3g noauto,rw,uid=1002 0 0
You can get the UUID of your device by looking at the output of 'ls -l /dev/disk/by-uuid' when the external drive is plugged.