LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Help for formatting external hdd !! (https://www.linuxquestions.org/questions/linux-hardware-18/help-for-formatting-external-hdd-123781/)

sudhir 12-08-2003 01:54 AM

Help for formatting external hdd !!
 
Hi

I got a new external hard disk, 160 GB, connected through USB !! The main purpose of this is to backup my data...

First, I dont know how to format this hard drive.

When I connected it to my computer (running RHL 7.3) it is recognized and shows up as /dev/sda5

Now.. I want to know how do I format this external hard drive because it has been formatted using windows, when I bought !!

And when I do

> /sbin/fdisk -l /dev/sda

I get

> Cannot open /dev/sda

So.. Could someone please help me set up this hard drive and then set up the backup process too !!

Maybe I can do with help on setting up the hard drive first !!!

TIA
-- Sudhir

sudhir 12-08-2003 02:00 AM

And one more note...

When I opened the "hardware browser", I saw the following, among other things....

- /dev/sda
|
|-sda5 2 19457 152617 FAT

the number columns being start > end > Size > Type

So in the Type column I see "FAT" ... Does this mean the external hdd I got already has a FAT partition ?? In that case, Linux does indeed recognise and work well with FAT partition right ???

:(

Sorry if my questions are elementary... :( but I am not familiar with such details in linux !!

Please help me people !!!

TIA
-- Sudhir

sudhir 12-08-2003 06:43 AM

Hi People

I could manage to partition the hdd using the mkfs command... I read the man pages and got done with it..

What I need to know now is how to set up the the backup facility in crontab!!

Could anyone guide me with regarding to writing a script or something to put in the crontab.daily ?? or is there any place where I can take a look at examples ??

Looking forward to your help !!

TIA
-- Sudhir

trogers 12-11-2003 02:08 PM

Sudhir here is my backup script, I am pulling from a remote drive to a local,but the principal for a usb drive would be the same idea. Just change the rsync line to /hdba1 /mnt/whateveryoucallyourexternaldrive. Also remove the ssh entry as you arent connecting to another machine. Check the man page for specifics on the flags you will want to use.

#!/bin/sh


echo "<RSYNC @`date`>" >> /var/log/rsync.log
rsync -ave ssh chronos:/export/ /mnt/hdb1/ >> /var/log/rsync.log 2>&1
echo "</RSYNC @`date`>" >> /var/log/rsync.log
RETVAL=$?


exit $RETVAL

save it to /usr/local/bin as rsync-something.sh

to setup the cron job> crontab -e
write an entry something like this
0 18 * * 1-6 /usr/local/bin/rsync-export.sh
I tend to mess this up when writing cron jobs, it's supposed to translate as: at 6pm monday-saturday run rsync-export.sh which is in /usr/local/bin

Hope this gets you started.
Thaddeus

sudhir 12-11-2003 11:30 PM

Hi Trogers..

Thanks a lot for ur message..

I got some info on using tar for the backup and I set it up... It has been working well for the past coupla days. What I did was write scripts for a daily incremental backup and a weekly full backup.. and automated this with crontab....

Anyway thanks for ur info pal.. I got rsync downloaded but din set it up coz I was able to set up the one with tar... :)

Thanks again !! :)

NOTE.. For others who might be wanting to do something like this and dont know how to do it (like I was a coupla days back... ;) ... ) Here is my script.... Hope this and the one with rsync posted by Trogers shud help you all !!

** This is for a Daily Incremental Backup !!!

#!/bin/sh
LastBackupTime=`cat /mnt/usd1/Last.txt`
tar czv --newer-mtime $LastBackupTime -f /mnt/usd1/`date '+%w'`.tgz /<dir you want to backup>
echo `date '+%Y-%m-%d'` > /mnt/usd1/Last.txt

Put this in /etc/cron.daily/<file name>... and make it executable !!!

** This one is for a Weekly Full Backup !!!

#!/bin/sh
mv /mnt/usd1/Full.tgz /mnt/usd1/Full.tgz.old
tar zcvf /mnt/usd1/Full.tgz /<dir you want to backup>
rm /mnt/usd1/Full.tgz.old
rm /mnt/usd1/0.tgz
rm /mnt/usd1/1.tgz
rm /mnt/usd1/2.tgz
rm /mnt/usd1/3.tgz
rm /mnt/usd1/4.tgz
rm /mnt/usd1/5.tgz
rm /mnt/usd1/6.tgz

Put this in /etc/cron.weekly/<file name> ... again make this one executable too...

What I have done is set up a daily incremental backup which will dump files like 0.tgz, 1.tgz......6.tgz
(0 being Sunday...)

And in the weekly full backup, I have made the previous week' full backup to be renamed and then the current week' full backup happens... and after this, the previous week' daily backup files and the full back files are removed ... This rountine is called rotation I think (thats wat I learnt fromthe websites) This is primarily done to save space on the external HDD...

And finally edited the /etc/crontab.... Actually there is no need to edit it if U have something like run-parts in the crontab file with separate daily, weekly, hourly or monthly sections....

So I just edited the crontab files with regard to the time... thats all !!!

And this has been doing the job well !!! Hope this helps !!!


All times are GMT -5. The time now is 06:42 PM.