# Dump Script With Cron



## TheStrategerist (Jun 20, 2012)

Hello! I am a brand new member (and a serious newbie to this OS), but referencing this forum has taught me everything I know about FreeBSD. I want to extend a very real thank you to all members and mods for asking and answering questions. 

I am attempting to back up my root directory with dump on a regular basis via crontab.

Here is what my crontab looks like, located in /var/cron/tab/root:


```
*   2   *   *   0   /bin/backup_script/backup.script
```

The backup script works when I run it. It looks like this.


```
#!/bin/sh
USER=root export USER
LOGNAME=root export LOGNAME
dump -0f /mnt/disk2/backup/horus_image.dump /
```

I did not write this, I snagged it here. To be honest, I'm not entirely sure what is going on in the first two active lines of the script. I've read the manual page on shells, but I'm still a bit confused about it all.

BUT!
Like I mentioned above, both the code and the bare command begin the dump, but cron does not. I know my cron formatting is correct, because I can assign it a periodic tar backup and it works fine.

I'm almost positive that this has to do with the fact that dump requires responses during the backup process (e.g. "Is the new volume mounted and ready to go?: ("Yes" or "No")) and this code is ill-equipped to deal with that. Or it could be something else entirely that I am missing. 

Do I need a more complex script to run dump in a crontab, or is there a simpler solution?

Thanks in advance for any help!


----------



## wblock@ (Jun 20, 2012)

The article explains why it is setting those variables.

Use the right options to dump, and it won't ask for input.  See Backup Options For FreeBSD.

Why it doesn't run should be explained either by the mail that cron(8) sends to root, or by this (#2).


----------



## DutchDaemon (Jun 20, 2012)

Also: dump lives in /sbin, which is not in cron's default search path. Use /sbin/dump and try again.

Oh sorry, yes, that was #2 above.


----------



## TheStrategerist (Jun 21, 2012)

Excellent! It's working now. 

Thanks for your article referral wblock@, very helpful. I adjusted the dump command to look like this:

[CMD=]/sbin/dump -C16 -b64 -0uanL -f /mnt/disk2/backup/horus_image.dump /[/CMD]

Though it seems entirely obvious now, I didn't understand that dump was making sure that the new tape was installed and mounted, since tape reels are a bit of a foreign concept to me. The -a option ignores all tape-length worries that dump might be having (and thus asking you about throughout the process). 

For newbies like me the manual pages can be a bit overwhelming. Now I see what it was saying, it was just a bit over my head. 

Thanks again guys!


----------

