Moved from Ubuntu to Mint16 and Backup Script fails

Forum rules
Before you post please read this

Moved from Ubuntu to Mint16 and Backup Script fails

Postby lemmingNO3 on Fri May 02, 2014 5:06 pm

64bit dual core Hp Media Center with 2 hard drives (Primary & Backup drives)
Mint 16
I am a nubie to bash scripts and programming. I'm also pretty sure I am confused and doing something pretty stupid...

I found a rsync based backup script a while back, which did incremental backups and I managed to change the code by finding examples with google of various portions of the coding so that it instead kept a perfect copy of my Primary drive on my Backup drive and then added some whistles and bells to make it a fun script. It ran once a day on Ubuntu and ran flawlessly. But I have encounted a strange problem in trying to get it to write to my Backup drive. It now insists on writing my personal data backup into my Primary Drive's / directory! -since I moved over to LinuxMint 16. There is some kind of difference between what I used on Ubuntu and on Mint, or there is something I don't understand about between the difference of addressing a single partition system and a multiple partition system.

My backup drive, when I was using Ubuntu, had everything in the / partition. But, since I redid everything upon moving to Mint16, Now both the Primary and the Backup drives have separate partitions for both / and /home.

I know I have the correct UUID for my /home partition on my Backup Drive, because the following command mounts it in my script:

Code: Select all
/usr/bin/udisks --mount /dev/disk/by-uuid/0dd5dc2c-1d21-4ad0-a113-855111089096

That still works just fine on Mint 16 that I can tell.

However, when I double check the path to my Backup Drive using Nemo (after mounting it) I discover that the path isn't the same as what it was on Ubuntu. On Ubuntu it apeared in the file manager as

Code: Select all
/media/disk/home/justme


-and it was written into my script as:

Code: Select all
ARCHIVEROOT="/media/disk/home/justme


But, that was when everything was in the / directory on that drive. However, in my new Mint 16 layout, / and /home each have their own partitions. So the statement must be different, but when I mount the Backup Drive in Nemo and then go look at the path in the "media" directory, it's weird, as my personal "justme" home directory appears BEFORE I see the UUID in the path! Here is Nemo's path to get to my Backup Drive:

Code: Select all
/media/justme/0dd5dc2c-1d21-4ad0-a113-855111089096/justme


So, I set ARCHIVEROOT:

Code: Select all
ARCHIVEROOT="/media/justme/0dd5dc2c-1d21-4ad0-a113-855111089096/justme"


And I run the script "sudo ./backup_local"

But it doesn't back up my Primary Drive's home directory of "justme" to the Backup Drive's directory of "justme". Instead, it backs up my Primary Drive's "justme" to my Primary Drive's /media/justme/0dd5dc2c-1d21-4ad0-a113-855111089096 location. It is seeing the "0dd5dc2c-1d21-4ad0-a113-855111089096" as just a directory, rather than a link to the drive. So, when the Backup Drive is unmounted, the "0dd5dc2c-1d21-4ad0-a113-855111089096" directory in my system partition now contains the backed up information....at least up to the point that it uses up all the space allotted in my system partition.

I'd appreciate any thoughts you might have on how to make this work. If you want to post the script, I'd be happy to do so. Thanks! :D
lemmingNO3
Level 1
Level 1
 
Posts: 3
Joined: Fri May 02, 2014 3:36 pm

Linux Mint is funded by ads and donations.
 

Re: Moved from Ubuntu to Mint16 and Backup Script fails

Postby WharfRat on Wed May 14, 2014 8:51 pm

lemmingNO3,

The only thing I can suggest is to create a mount point for your backup e.g., /media/backup. Change the owner:group to your user name and use mount rather than udisks to mount the partition.

Code: Select all
sudo mkdir /media/backup

Code: Select all
sudo chown $USER:$USER /media/backup

Code: Select all
sudo mount UUID=0dd5dc2c-1d21-4ad0-a113-855111089096 /media/backup/


Then simply adjust your script to use the new mount point.

Another thing you can do is check for the existence of a file on the backup media e.g., create a file called backup_media then in your script

Code: Select all
[[ ! -e /media/backup/backup_media ]] && exit 1


That will at least prevent it from writing to the wrong place.

Good luck :wink:
Image
User avatar
WharfRat
Level 11
Level 11
 
Posts: 3771
Joined: Thu Apr 07, 2011 8:15 pm

Re: Moved from Ubuntu to Mint16 and Backup Script fails

Postby Mint_BackupRestore on Sat May 17, 2014 4:03 am

Dear lemmingNO3,

what WharfRat already posted is good advice. You can try that. But to fully understand the issue it would be great if you could post your entire bash script. Using rsync is a excellent way to backup data!

This is how I would resolve the issue. First of all there is a file under /etc/ in Linux Mint called fstab. This file tells the system upon startup were it will mount each drive. Here you can adjust it yourself but make sure to make a backup.

Example (from my fstab):

#Backup
#/dev/sdb1 /media/Backup ntfs defaults 0 0
UUID=05E2F3B641730B45 /media/Backup ntfs rw,nouser,dev,async,uid=1000,gid=46 0 0


This tells Linux when booting to mount the drive with an UUID of 05E2F3B641730B45 under the folder /media/Backup.

I have a further line in the fstab saying:
# Daten (D:)
#/dev/sdc2 /media/Daten ntfs defaults 0 0
UUID=32452F737DC62CC0 /media/Daten ntfs defaults,uid=1000,gid=46 0 0


This tells Linux when booting to mount the drive with an UUID of 32452F737DC62CC0 under the folder /media/Daten.

Then all I have to put into a script is:
echo "Starting backup of Data to Backup drive"
rsync -auv --log-file=/home/user/$(date +%Y%m%d)_rsync.log --progress /media/Daten/ /media/Backup
echo "Backup script has finished. Have a nice day."
read -p "Press any key to continue... " -n1 -s


...and your backup will start.

Alternatively you can just type "rsync -auv --log-file=/home/user/$(date +%Y%m%d)_rsync.log --progress /media/Daten/ /media/Backup" into the terminal.

Have a nice Weekend,
Bastian

P.S. Check out this link if my examples on fstab weren't sufficient: https://wiki.archlinux.org/index.php/Fstab

=========================================================================================================
A new search engine alternative to google: https://www.ixquick.com/do/search
Backup and Restore your Linux Mint Settings: http://forums.linuxmint.com/viewtopic.php?f=42&t=167083&p=859458&hilit=backup+restore+settings#p859458
Mint_BackupRestore
Level 1
Level 1
 
Posts: 24
Joined: Sat May 10, 2014 11:19 am


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 2 guests