Author Topic: Backup  (Read 885 times)

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Backup
« on: 10 December 2002, 08:06 »
This is in /etc/cron.daily, and it should supposedly make me backups:

Code: [Select]

Why isn't the damn thing working? I cd-ed into /home2/backup and none of the backups are there. What the hell?

I did ls -l /home2, and I got the following:

[gleb@gleb /]$ ls -l home2
total 20
drwxr-xr-x    2 root     root         4096 Dec  8 14:24 backup
drwx------    2 root     root        16384 Nov 21 10:06 lost+found

Now, I don't want anything besides the cron script writing here. What do I do?

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Backup
« Reply #1 on: 10 December 2002, 08:14 »
I know that this is a premission thing, but how do I find the UID for the script?

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Backup
« Reply #2 on: 10 December 2002, 08:18 »
I would personally never run my backups from cron.daily but there really isn't a reason they shouldn't run. The reason I don't is because I want to pick a specific time to run the backups. cron.daily is run at 4:02am by default (at least on my system according to /etc/crontab).

I run my backups directly from root's crontab. When you do this, any error messages if not redirected to a file will go to root's mailbox. Check root's mail and see if there are any error messages. I usually redirect the output to a file so I can check on any problems, e.g.:

0 2 * * * /root/bin/backup > /root/logs/backup.log 2>&1

The above command is just an example and not one I use. I actually use Amanda for backups. But I'll copy your script into a file and see if I can figure out what might be wrong. One thing you usually want to do when running a script from cron is to use full paths for every command in the script. Some ~/*rc files are not processed and may not contain the full path that you have access to when in a login shell.

I'll let you know what I find out.
Someone please remove this account. Thanks...

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Backup
« Reply #3 on: 10 December 2002, 08:20 »
Actually, browsing over your script it appears that you have considered the PATH. I assume it runs from the command line?
Someone please remove this account. Thanks...

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Backup
« Reply #4 on: 10 December 2002, 08:24 »
Yes, I only have access to cli. . .

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Backup
« Reply #5 on: 10 December 2002, 08:28 »
If I let it run using the root crontab, it'll have root priviliges, right?

so. . .

0 2 * * * /etc/cron.daily.backup.cron > /root/logs/backup.log 2>&1

Would work perfectly? I just need crude backup of the /home directory!

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Backup
« Reply #6 on: 10 December 2002, 08:41 »
It will run under root in both root's crontab and in cron.daily, no difference other than you can't specify a time apart from the other cron.daily tasks. Do the directories exist that are defined at the top of the script?  Did you try and run the script on the command line?

The first thing that is wrong is there is a "fi" missing at the very end. You need to make sure the directories exist that are defined at the top of the script. And in your case you need to make sure the "$TIMEDIR/gleb-full-date" file exists. If it does not create it by:

# echo "09-Nov" > /backups/last-full/gleb-full-date

Make sure the "/home2/backup" and "/backups/last-full" directories exist. If you don't want the stuff going to those directories just change the variables at the top of the script. It runs fine on my machine after doing the above.

[ December 10, 2002: Message edited by: void main ]

Someone please remove this account. Thanks...

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Backup
« Reply #7 on: 10 December 2002, 21:18 »
Aha, I did it, and it worked! Thank Void! This should definetly go into the FAQ!

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Backup
« Reply #8 on: 10 December 2002, 21:20 »
No problem. I wouldn't put the script in /etc BTW. Put it somewhere else... but that just may be more of a personal preference.
Someone please remove this account. Thanks...

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Backup
« Reply #9 on: 10 December 2002, 21:37 »
quote:
Originally posted by void main:
No problem. I wouldn't put the script in /etc BTW. Put it somewhere else... but that just may be more of a personal preference.


Where would you stick it? I got the hand of cron (such a simple concept, I should've read about it a year ago. It would've made life SO much easier!)

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Backup
« Reply #10 on: 10 December 2002, 10:02 »
Well you can see from my previous crontab example where I would more prefer to run it from. It's running under root so I put it in root's home. Of course, /usr/local/sbin wouldn't be a bad place either.

[ December 10, 2002: Message edited by: void main ]

Someone please remove this account. Thanks...