Automatic backup to 2nd HDD - Please advice exact steps

I’m new here and no Pro in programming yet :slight_smile:
Nextcloud on my Pi 3B using a 16GB Sandisk SD card sucessfully installed.
Connected a 2.5" HDD to the Pi and set this HDD as the target drive for all my Fotos and documents.
Normal precedure, most of it automatically done by Nextcloud.
Everything is running until here.

No my problems begin:
Using THE SAME TYPE of HDD (I bought 2x 2GB Seagate) as a backup drive doesn’t work because I don’t know how to tell the Pi that the second drive is different to the first on (both are named as /media/USBdrive etc…). So the Pi stucks until I remove the 2nd disk and reboot if I remember right…I think the problem is that Nextcloud cannot distinguish between both drives and does’nt know the right pathes to its directories…?

So my question is: WHAT and HOW (I’m a Linux beginner) to do to use 2 EXACT same HDD types one as my cloud (this already works fine) and the other for periodically (one a day?) mirror the first one (the data = Fotos, documents etc.) as a backup if the first disk crashes somehow?!!

I know there’s an article on Github about that (How to periodically backup to a second USB drive with NextCloudPi) but I don’t really check all this resp. the right steps, tried it but didn’t solve it this was :frowning:

My aim is only to use one Seagate 2.5" for normal use and the second Seagate 2.5" for automatically periodic backups of my data (or does anyone recommended more…?) in terms the primary disk crashes.

Thanks a lot and BR,

Each device (e.g. sd card, usb key, usb hdd) has an unique UUID, you can count on it to differentiate your 2 hdd.

plug in one hdd, run in a terminal

lsblk -o +uuid

the right most long string is the UUID of this device. Copy it.
Repeat above step for the next hdd.

To mount the hdd, just replace the /dev/sdx1 with UUID=“xxxx-xxx-xx-x-xxx” in your mount statement or /etc/fstab.

rsync should be command to do the backup. Don’t forget to set NC’s maintenance mode on by occ before run it. Suggest you read the document here as well.

Hi and thanks for your Reply.
Got it, but cannot resolve it.
Pls have a look at my attached screenshot.
On top you see your suggested command with my “main” HDD, which already is integrated in my nextcloud and working.
Below you see my fstab file opend with nano.
Where and how to put this Long uuid?
And where and how to put the second (my backup drive)?
And how resp. where (Web-Gui?) exactly do I setup nextcloudpi after?


PARTUUID/PARTLABEL identifies a GPT partition. UUID/LABEL identifies a filesystem.
So, PARTuuid is NOT part of uuid.

Every line in /etc/fstab mounts one device to a mount point. what you have now only mount the basic linux system.

add a 3rd line to mount your “main” HDD (so as to have it auto-mounted during every boot)
1st colume is UUID=6c672b…(copy the whole string)
2nd colume is the mount point you assigned

As you sound to me that you are new to linux, PLEASE BE WARNED that if you make mistake in /etc/fstab, you can make your rpi not bootable.
note 1 after you update /etc/fstab, run “mount -a” to see if there is any error/warning message. if yes, fix them before reboot. YOU’RE WARNED AGAIN.
note 2 when you google mount /etc/fstab, no need to worry too much on those options (i.e. 4th column), I have one word “defaults” on mine.
note 3 in case of shit happen, mount you sdcard to a PC to edit /etc/fstab back.

After your “main” HDD is fixed, prepare a mount script with the UUID of your 2nd HDD for easy handling. If you want to learn a bit more, read the noauto option of /etc/fstab to replace the script. Remember to run “mount -a” after any change on /etc/fstab before reboot.

Thanks a lot :slight_smile:

I’l try the next days…