bit of a mess up

Associate
Joined
19 Jul 2006
Posts
1,847
have a linux machine running suse that i was trying to use as backup machine
i was running a script on there
Code:
#/bin/sh
mkdir - p /backups/
cd /backups/
scp -r 10.0.6.22:/temp/backups

the script work fine and just bulls across the data.
thing is the data been pulled across is not to big for the hd on the box. how would i go about connecting an external hd and then modifying the script?

TIA
 
have a linux machine running suse that i was trying to use as backup machine
i was running a script on there
Code:
#/bin/sh
mkdir - p /backups/
cd /backups/
scp -r 10.0.6.22:/temp/backups

the script work fine and just bulls across the data.
thing is the data been pulled across is not to big for the hd on the box. how would i go about connecting an external hd and then modifying the script?

TIA

wait hang on...

make a directory, cd to it, then copy the contents of a remote folder to the directory you just made... if you're going to run this more than once, then surely the folder exists, thererfore the first line is redundant?

Anyway... if you don't every power off the suse box, then simply mount the external disk on /backups, cut the first line of the script any off you go.

plug in usb drive
Code:
$ dmesg | tail | grep /dev/
will tell you the device node for the external disk
Code:
# mount /$DEVICE /backups
- where $DEVICE is the /dev/XXXX bit from the previous command - will mount the drive (if the external drive is ntfs, that will mount read-only - if it's ntfs, then use
Code:
# mount /dev/$DEVICE /backups -t ntfs-3g
and off you go.

If you need to reboot the box, then you'll either need to run that *every* time, or either add an entry to fstab or configuring hal.

fstab would look something like this and would rely on you either issuing the mount command or having the disk in when booting. HAL is generally better - but can have problems mounting ntfs read-write.
Code:
UUID=$UUID_OF_YOUR_DISK         /backups        $YOUR_FILESYSTEM    user,rw 0 0
Best to use the uuid, as the device node may change depending on what else you have plugged in. you can find that with
Code:
ls -l /dev/disk/by-uuid/
Because of the "user,rw" options in that line, you can mount the disk in the right place as a user when you plug it in with
Code:
$ mount /backups
EDIT: Actually - you could add that to your script.





Or something like that.

If Linux was a car, then it would have eighteen steering wheels and no air conditioning, but you'd be able to change the radio station from the hubcaps
 
Last edited:
yeah sorry typo's in there and running as root. The box should be running all time and located in the office just for this job.
Cheers .walls, i realise the first line is redundent so i ll get rid of that. Can you explane this

plug in usb drive
Code:

$ dmesg | tail | grep /dev/

will tell you the device node for the external disk
Code:

# mount /$DEVICE /backups

- where $DEVICE is the /dev/XXXX bit from the previous command - will mount the drive (if the external drive is ntfs, that will mount read-only - if it's ntfs, then use
Code:

# mount /dev/$DEVICE /backups -t ntfs-3g

and off you go.

is the external hd now becoming the backup directory or is it located with in there?

TIA
 
is the external hd now becoming the backup directory or is it located with in there?

The first line is to help you find the device node of the external drive. so we're calling "dmesg" and piping it into "tail", so we only have the last ten lines of the dmesg output.
Then, we're piping that into grep and looking for a line with /dev/ in it. it will be in a similar format as "/dev/sdb1". this is the device node that we're looking for.

/backups already exists, so you can mount the drive over this folder with the mount command (-t is optional to tell the os what type of filesystem you're mounting, so for read-write ntfs, you'd use ntfs-3g as opposed to the inbuilt kernel module).

so yes, the external drive will get mounted on the /backups folder like that.

That script can easily be run as a user account (modify the permissions on the /backups folder) and you shouldn't have root access enabled over ssh - you really should look into changing that.
 
Back
Top Bottom