Troubleshooting – Time Slider (zfs snapshots)

1. snapshot complains about no access to cron

This problem i came across was after i was playing with crontab. It looks like the zfs snapshot service uses an account called “zfssnap” and if it doesnt have access to cron then it will have issues creating / checking snapshots. Check the file /etc/cron.d/cron.allow and ensure that “zfssnap” is in there. The issues i had looked like this in the log…   (check the logs via the log file viewer)

Checking for non-recursive missed // snapshots  rpool

Checking for recursive missed // snapshots protected rpool/backup rpool/export rpool/ROOT unprotected

crontab: you are not authorized to use cron.  Sorry.

crontab: you are not authorized to use cron.  Sorry.

Error: Unable to add cron job!

Moving service to maintenance mode.

The actual crontab lives in the /var/spool/cron/crontab/zfssnap file. (don’t edit this manually)

Restart the services by clearing the maintenance status then if required enable or restart like so…

svcadm clear auto-snapshot:frequent

svcadm enable auto-snapshot:frequent

Check that all zfs snapshot services are running as expected….

svcs -a | grep snapshot

online         22:26:12 svc:/system/filesystem/zfs/auto-snapshot:weekly

online          9:06:36 svc:/system/filesystem/zfs/auto-snapshot:monthly

online          9:11:23 svc:/system/filesystem/zfs/auto-snapshot:daily

online          9:12:00 svc:/system/filesystem/zfs/auto-snapshot:hourly

online          9:23:57 svc:/system/filesystem/zfs/auto-snapshot:frequent

2. snapshot fails with dataset busy error

Seen something similar to this in the logs? …

Checking for recursive missed // snapshots protected rpool/backup rpool/export rpool/ROOT unprotected

Last snapshot for svc:/system/filesystem/zfs/auto-snapshot:frequent taken on Sun Mar 15 22:26 2009

which was greater than the 15 minutes schedule. Taking snapshot now.

cannot create snapshot 'rpool/ROOT/opensolaris@zfs-auto-snap:frequent-2009-03-16-09:06': dataset is busy

no snapshots were created

Error: Unable to take recursive snapshots of rpool/ROOT@zfs-auto-snap:frequent-2009-03-16-09:06.

Moving service svc:/system/filesystem/zfs/auto-snapshot:frequent to maintenance mode.

Here is an bit from this site – “This problem is being caused by the old (IE: read non-active) boot environments not being mounted and it is trying to snapshot them. You can’t ‘svcadm clear’ or ‘svcadm enable’ them because they will still fail.”

Apparently a bug with the zfs snapshots similar to /root/opensolaris type pools — anyhow to fix i’ve just used a custom setup in time slider. Clear all the services set to “maintenance” then launch time-slider-setup and configure to exclude the problem pools.

Update : As per Johns comments below you can disable the snapshots on the offending zfs system using the following command…

zfs set com.sun:auto-snapshot=false rpool/ROOT

As above to clear “maintenance” status on the effected services run the following command…

svcadm clear auto-snapshot:hourly

svcadm clear auto-snapshot:frequent

Now run this to ensure all the SMF services are running without issue…

svcs -x

If all is well you will get no output.

Linux – crontab

Time to schedule some tasks!

First you need to make sure your in the /etc/cron.d/cron.allow file. If you are not SU to root and add yourself into it.

Now to create your new crontab file;

crontab -e

You are in vi in your newly created crontab file (note if you do not have access to do this it will say so)

Now, i’m no expert at using vi, but if you press i you will go into insert mode. Do this, then type the cron job details. A typical cron job will look like this

0 4 * * * /export/home/user/backup.sh

so there are five slots before the command you want to run. They are: min, hour, day, month, day-week. So my example above will run at 4am every day. See below for more detail.

once you have entered the line press ESC then type :wq to save and quit.

To confirm the job has been saved successfully in cron type this command;

crontab -l  this will show you your current scheduled tasks, it should output the above job.

In OpenSolaris the crontab files are located at /var/spool/cron/crontabs/ they are named after the specific user. Sometimes its easier to go there than to use vi, but make sure your permissions are all set correctly before editing any system files.

In some distros there are folders like /etc/cron.daily/ which run any scripts inside them on a schedule matching the folder name.

This is a bit more on the format of the 5 timings within the crontab file;

*     *   *   *    *  command to be executed

|     |     |     |     |
|     |     |     |     +—– day of week (0 – 6) (Sunday=0)
|     |     |     +——- month (1 – 12)
|     |     +——— day of month (1 – 31)
|     +———– hour (0 – 23)
+————- min (0 – 59)

Update

@reboot is also another very handy cron modifier. I use the following quite a lot…
@reboot /bin/sleep 600 ; /path/to/your/your_program@reboot /bin/sleep 600 ; /path/to/your/your_program