Back In Time 设置为每天连接外部磁盘后立即开始备份。这会产生一个 udev 规则,该规则使用 Back In Time 生成的配置文件启动 anacron。不幸的是,备份无法运行,因为 anacron 总是抛出错误anacron: Can't open timestamp file for job 1_Main_profile: Read-only file system
(在系统日志中看到)。如果手动启动(以root
用户和普通用户身份启动jdoe
),则 Back In Time 作为 udev 规则生成的命令运行良好。 (通过 GUI 手动启动时,备份也运行良好。)
我很乐意至少找出 anacron 无法打开的文件,当然还有原因。
udev
规则:
ACTION=="add", ENV{ID_FS_UUID}=="dd68d7f7-054b-dae0-a4a2-4315acad138a", RUN+="/bin/su - 'jdoe' -c 'test -x /usr/sbin/anacron && test -e /home/jdoe/.config/backintime/anacrontab-dd68d7f7-054b-dae0-a4a2-4315acad138a && /usr/sbin/anacron -s -t /home/jdoe/.config/backintime/anacrontab-dd68d7f7-054b-dae0-a4a2-4315acad138a -S /home/jdoe/.local/share/backintime/anacron' &"
anacrontab
,现在修改为仅进行日志记录,原始文件(不带logger "… " ||
)在手动执行时确实可以正常启动备份,但不能自动启动:
$ cat /home/jdoe/.config/backintime/anacrontab-dd68d7f7-dae0-4315-a4a2-054bacad138a
SHELL=/bin/bash
PATH=/home/jdoe/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
DISPLAY=:0.0
1 0 1_Main_profile /usr/bin/logger "would start backup now, but exiting, as you set in anacrontab :-)" || /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /usr/bin/backintime --backup-job >/dev/null 2>&1
文件/文件夹(通过运行不符合规则的 anacron 命令来设置“1_Main_profile”的权限udev
):
$ ls -ld /home/jdoe/.local/share/backintime/anacron/
drwxrwxrwx 2 jdoe jdoe 4096 Jul 18 10:41 /home/jdoe/.local/share/backintime/anacron/
$ ls -l /home/jdoe/.local/share/backintime/anacron/
insgesamt 8
-rw------- 1 jdoe jdoe 9 Jul 18 10:42 1_Main_profile
$ groups jdoe
jdoe : jdoe adm cdrom sudo dip plugdev lpadmin sambashare vboxusers
$ ls -ld /var/spool/anacron/
drwxrwxr-x 2 root adm 4096 Apr 30 2016 /var/spool/anacron/
$ ls -l /var/spool/anacron/
insgesamt 12
-rw------- 1 root root 9 Jul 18 10:20 cron.daily
-rw------- 1 root root 9 Jun 29 09:07 cron.monthly
-rw------- 1 root root 9 Jul 18 10:24 cron.weekly
手动启动 udev 规则之外的命令(如root
via ssh
,在不使用上面的“的情况下启动logger "…" ||
它将启动备份):
$ /bin/su - 'jdoe' -c 'strace /usr/sbin/anacron -s -t /home/jdoe/.config/backintime/anacrontab-dd68d7f7-054b-dae0-a4a2-4315acad138a -S /home/jdoe/.local/share/backintime/anacron &> /dev/shm/strace-anacron-backintime'
X11 connection rejected because of wrong authentication.
$ cat /dev/shm/strace-anacron-backintime
execve("/usr/sbin/anacron", ["/usr/sbin/anacron", "-s", "-t", "/home/jdoe/.config/backintime/"..., "-S", "/home/jdoe/.local/share/backin"...], [/* 26 vars */]) = 0
brk(NULL) = 0x562556b3c000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f75287a6000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=178056, ...}) = 0
mmap(NULL, 178056, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f752877a000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\3\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1685264, ...}) = 0
mmap(NULL, 3791264, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f75281e8000
mprotect(0x7f752837d000, 2093056, PROT_NONE) = 0
mmap(0x7f752857c000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x194000) = 0x7f752857c000
mmap(0x7f7528582000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f7528582000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7528778000
arch_prctl(ARCH_SET_FS, 0x7f7528778700) = 0
mprotect(0x7f752857c000, 16384, PROT_READ) = 0
mprotect(0x5625560cc000, 4096, PROT_READ) = 0
mprotect(0x7f75287a9000, 4096, PROT_READ) = 0
munmap(0x7f752877a000, 178056) = 0
brk(NULL) = 0x562556b3c000
brk(0x562556b5d000) = 0x562556b5d000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=3259968, ...}) = 0
mmap(NULL, 3259968, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f7527ecc000
close(3) = 0
open("./", O_RDONLY) = 3
chdir("/home/jdoe/.local/share/backintime/anacron") = 0
umask(000) = 022
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
close(0) = 0
open("/dev/null", O_RDONLY) = 0
close(1) = 0
open("/dev/null", O_WRONLY) = 1
close(2) = 0
open("/dev/null", O_WRONLY) = 2
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f75287789d0) = 4473
exit_group(0) = ?
+++ exited with 0 +++
答案1
有问题的时间戳文件是/home/jdoe/.local/share/backintime/anacron/1_Main_profile
.请确保它是可写的。您还可以保存以将其删除。 Anacron 下次会写一篇新的。
但我也建议更新到更新的 BiT 版本(当前稳定版是 1.1.20)。不久前,我用纯 Python 代码替换了 anacron 依赖项,这使得该计划更加可靠。