Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incremental ufsdump in cron job 1

Status
Not open for further replies.

Rasslor

Technical User
Dec 13, 2000
52
0
0
US
Hey all,

I hope you can help me with this. I'm looking to setup incremental backups on my solaris 9 box. When I'm doing my full backups from single user mode I'm using :

First we are mounting to our drive for backups.
mount /dev/dsk/c0t0d0s7 /mnt

Then we are dumping each slice one at a time.
ufsdump 0vf /mnt/c1t0d0s0.ufs /dev/rdsk/c1t0d0s0
ufsdump 0vf /mnt/c1t0d0s3.ufs /dev/rdsk/c1t0d0s3
ufsdump 0vf /mnt/c1t0d0s5.ufs /dev/rdsk/c1t0d0s5
ufsdump 0vf /mnt/c1t0d0s6.ufs /dev/rdsk/c1t0d0s6
ufsdump 0vf /mnt/c1t0d0s7.ufs /dev/rdsk/c1t0d0s7

What I'm looking to do is setup a cron job that will do Monday through Thursday incremantals and Friday differentials. I am unsure how to setup a script to do this since I am writing to a harddrive and not a tape. I'm also not sure how to set it up to dump each slice without it being 5 different cron jobs every night.

I would greatly appreciate anyone who can help me with this.

Thank you
 
All you need to do is put all of the commands you posted into a script and run that from cron instead.

You could replace 0vf with ${1}vf and pass the backup level to the script as a parameter. You could do a level 0 on Friday and level 1s every other day of the week, although a common strategy for large filesystems would be something like level 0 on Sunday, 1 on Monday, 2 on Tuesday, 3 on Wednesday, 1 on Thursday, 2 on Friday and 3 on Saturday.

Personally if it's just single slices of a single disk I would just do level 0's every day.

Annihilannic.
 
Unfortunatly right now I'm trying to do this with the small amount of support I'm getting at my job, amazing how for a million dollar project asking for a $3000 tape drive is too expensive. The other drive I'm writing to isn't very big so thats why I'm forced to do incrementals until my real backup software solution is purchased. I've never written a script for doing these backups as a cron job so that is really where I need most of my help.

thanks
 
You've already written it. Put all of those commands in a file, make it executable, and run it - voilà!

Annihilannic.
 
Annihilannic thanks for everything so far. Like I said I've never done this before so all your help is definatly appreciated. Quick question how would I be able to change the script to know if it's monday tuesday etc with the ${1}vf ? I get the feeling that I am just making this way more complicated than it really is, but I truely appreciate the help.

Would I just create five similar things in the script like:

#!/sbin/sh
#
# "Backup script
#

#mount backup disk
mount /dev/dsk/c0t0d0s7 /mnt

case "$1" in
'start')
ufsdump 1vf /mnt/c1t0d0s0.ufs1 /dev/rdsk/c1t0d0s0
ufsdump 1vf /mnt/c1t0d0s3.ufs1 /dev/rdsk/c1t0d0s3
ufsdump 1vf /mnt/c1t0d0s5.ufs1 /dev/rdsk/c1t0d0s5
ufsdump 1vf /mnt/c1t0d0s6.ufs1 /dev/rdsk/c1t0d0s6
ufsdump 1vf /mnt/c1t0d0s7.ufs1 /dev/rdsk/c1t0d0s7
;;

case "$2" in
'start')
ufsdump 2vf /mnt/c1t0d0s0.ufs2 /dev/rdsk/c1t0d0s0
ufsdump 2vf /mnt/c1t0d0s3.ufs2 /dev/rdsk/c1t0d0s3
ufsdump 2vf /mnt/c1t0d0s5.ufs2 /dev/rdsk/c1t0d0s5
ufsdump 2vf /mnt/c1t0d0s6.ufs2 /dev/rdsk/c1t0d0s6
ufsdump 2vf /mnt/c1t0d0s7.ufs2 /dev/rdsk/c1t0d0s7
;;
case "$3" in
'start')
ufsdump 3vf /mnt/c1t0d0s0.ufs3 /dev/rdsk/c1t0d0s0
ufsdump 3vf /mnt/c1t0d0s3.ufs3 /dev/rdsk/c1t0d0s3
ufsdump 3vf /mnt/c1t0d0s5.ufs3 /dev/rdsk/c1t0d0s5
ufsdump 3vf /mnt/c1t0d0s6.ufs3 /dev/rdsk/c1t0d0s6
ufsdump 3vf /mnt/c1t0d0s7.ufs3 /dev/rdsk/c1t0d0s7
;;
case "$4" in
'start')
ufsdump 4vf /mnt/c1t0d0s0.ufs4 /dev/rdsk/c1t0d0s0
ufsdump 4vf /mnt/c1t0d0s3.ufs4 /dev/rdsk/c1t0d0s3
ufsdump 4vf /mnt/c1t0d0s5.ufs4 /dev/rdsk/c1t0d0s5
ufsdump 4vf /mnt/c1t0d0s6.ufs4 /dev/rdsk/c1t0d0s6
ufsdump 4vf /mnt/c1t0d0s7.ufs4 /dev/rdsk/c1t0d0s7
;;
'stop')
 
Yes, you are making it more complicated than it is. :)

It looks like you have based this script on a boot-time startup script for some service, which usually takes parameters like 'start' and 'stop'.

All you need is the following:

Code:
#!/sbin/sh
#
# "Backup script
#

#mount backup disk
mount /dev/dsk/c0t0d0s7 /mnt

ufsdump ${1}vf /mnt/c1t0d0s0.ufs${2} /dev/rdsk/c1t0d0s0
ufsdump ${1}vf /mnt/c1t0d0s3.ufs${2} /dev/rdsk/c1t0d0s3
ufsdump ${1}vf /mnt/c1t0d0s5.ufs${2} /dev/rdsk/c1t0d0s5
ufsdump ${1}vf /mnt/c1t0d0s6.ufs${2} /dev/rdsk/c1t0d0s6
ufsdump ${1}vf /mnt/c1t0d0s7.ufs${2} /dev/rdsk/c1t0d0s7

Let's say this is called /usr/local/bin/mybackupscript and you want to implement the backup strategy I described with backups running at 01:00 every morning, you would add cron jobs such as:

[tt]00 01 * * * 0 /usr/local/bin/mybackupscript 0 0
00 01 * * * 1 /usr/local/bin/mybackupscript 1 1
00 01 * * * 2 /usr/local/bin/mybackupscript 2 2
00 01 * * * 3 /usr/local/bin/mybackupscript 3 3
00 01 * * * 4 /usr/local/bin/mybackupscript 1 4
00 01 * * * 5 /usr/local/bin/mybackupscript 2 5
00 01 * * * 6 /usr/local/bin/mybackupscript 3 6[/tt]

That way it substitutes the first parameter, ${1}) as the backup level, and the second parameter ${2}) as the numeric day of the week so that different filenames are used each day.

Since you mount the destination filesystem at the beginning of the script, should you also umount it at the end?

Annihilannic.
 
Thank you so much Annihilannic. I knew I was definatly making this thing way more dificult than it needed to be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top