bolthole / zrep

ZREP ZFS based replication and failover script from bolthole.com
Other
251 stars 57 forks source link

zrep2 (bash) not working via cronjob #190

Open HWesterhof opened 2 years ago

HWesterhof commented 2 years ago

I used the script from here: https://github.com/bolthole/zrep/blob/zrep2/zrep

When run from SSH shell, no issues here:

root@proxmox:~# pwd
/root
root@proxmox:~# whoami
root
root@proxmox:~# /usr/sbin/zrep -S zfs-ssd/subvol-100-disk-0
sending zfs-ssd/subvol-100-disk-0@zrep_000004 to localhost:zfs-hd/subvol-100-disk-0
Expiring zrep snaps on zfs-ssd/subvol-100-disk-0
Also running expire on localhost:zfs-hd/subvol-100-disk-0 now...
Expiring zrep snaps on zfs-hd/subvol-100-disk-0

But when I try using a cronjob:

0 */12 * * * /usr/sbin/zrep -S zfs-ssd/subvol-100-disk-0

WARNING: old ZFS version detected with no depth protection
WARNING: You may not nest zrep managed filesystems
/usr/sbin/zrep: line 1999: zfs: command not found
Error: zfs-ssd/subvol-100-disk-0 not master. Cannot sync

More info:

root@proxmox:~# cat /etc/debian_version
11.1
root@proxmox:~# bash --version
bash --version
GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu)

Also added this line to my /root/.bashrc file, with no effect:

export PATH="/usr/sbin:$PATH"

ppbrown commented 2 years ago

/root/.bashrc has no effect on crontabs. cron typically ignores user environment, and that includes the root "user".

There are multiple possible ways to properly set things like PATH for cron environment. It depends on the OS. One of the more common ones, is actually to just put

PATH=/what/you/want

at the top of the crontab file. Please read the docs for your OS for more details.

On Sat, Apr 2, 2022 at 10:42 AM HWesterhof @.***> wrote:

I used the script from here: https://github.com/bolthole/zrep/blob/zrep2/zrep

When run from SSH shell, no issues here:

@.:~# pwd /root @.:~# whoami root @.:~# /usr/sbin/zrep -S zfs-ssd/subvol-100-disk-0 sending @._000004 to localhost:zfs-hd/subvol-100-disk-0 Expiring zrep snaps on zfs-ssd/subvol-100-disk-0 Also running expire on localhost:zfs-hd/subvol-100-disk-0 now... Expiring zrep snaps on zfs-hd/subvol-100-disk-0

But when I try using a cronjob:

0 /12 /usr/sbin/zrep -S zfs-ssd/subvol-100-disk-0

WARNING: old ZFS version detected with no depth protection WARNING: You may not nest zrep managed filesystems /usr/sbin/zrep: line 1999: zfs: command not found Error: zfs-ssd/subvol-100-disk-0 not master. Cannot sync

More info:

@.***:~# cat /etc/debian_version 11.1

@.***:~# bash --version bash --version GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu)

Also added this line to my /root/.bashrc file, with no effect:

export PATH="/usr/sbin:$PATH"

— Reply to this email directly, view it on GitHub https://github.com/bolthole/zrep/issues/190, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANEV6PUUUAHCWMQ4O7TUKTVDCBJBANCNFSM5SLHBAQA . You are receiving this because you are subscribed to this thread.Message ID: @.***>