惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
AI
AI
L
LINUX DO - 最新话题
H
Heimdal Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The GitHub Blog
The GitHub Blog
I
Intezer
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
S
Securelist
博客园_首页
IT之家
IT之家
Schneier on Security
Schneier on Security
博客园 - 叶小钗
罗磊的独立博客
WordPress大学
WordPress大学
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
W
WeLiveSecurity
The Register - Security
The Register - Security
D
DataBreaches.Net
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
Recorded Future
Recorded Future
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tailwind CSS Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
T
Tor Project blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com

Tevin Zhang |

修复群晖 WebDAV 的 CORS 问题,不改 Nginx 独立开发者的开发者市场陷阱 我如何管理了 12 年的笔记 家用小型管理交换机对比 不要把企业当人看 在OpenBSD上进行私有Git托管 联邦宇宙平台评估 在 Jekyll 中使用 “details” 元素 数据存储与文明的衰落
在 Yunohost 上备份 crontabs
Tevin Zhang · 2023-09-16 · via Tevin Zhang |

YunoHost通常已经知道需要备份什么。但是,如果您进行了手动更改,例如在YunoHost应用程序系统之外安装了应用程序,您可能希望扩展YunoHost的机制以指定其他要备份的文件。

我使用borg作为备份方法,并在检查归档(以 _auto_conf_auto_data 为前缀)后发现crontab文件未包含在内。

阅读官方文档后,我成功备份了它们。

步骤

只需两个钩子文件,这对于除borg以外的备份方法也适用。

备份中将包括:

  • /var/spool/cron/crontabs 所有用户的 crontab -l
  • 两个钩子文件

注意:

  1. 所有操作均以 root 用户执行。
  2. 如果更改钩子文件的名称,请相应调整文件内容。

创建钩子文件夹

mkdir -p /etc/yunohost/hooks.d/{backup,restore}

创建备份钩子

/etc/yunohost/hooks.d/backup/99-conf_custom

内容
#!/bin/bash

# 引入YNH助手
source /usr/share/yunohost/helpers

ynh_restore_dest (){
    YNH_CWD="${YNH_BACKUP_DIR%/}/$1"
    cd "$YNH_CWD"
}


# 在子命令错误或未设置变量时退出钩子
ynh_abort_if_errors

# Crontabs
ynh_restore_dest "conf/custom/crontabs"
ynh_restore_file "/var/spool/cron/crontabs"

# 其他(包括此文件)
ynh_restore_dest "conf/custom/misc"
ynh_restore_file "/etc/yunohost/hooks.d/backup/99-conf_custom"
ynh_restore_file "/etc/yunohost/hooks.d/restore/99-conf_custom"

创建还原钩子

/etc/yunohost/hooks.d/restore/99-conf_custom

内容
#!/bin/bash

# 引入YNH助手
source /usr/share/yunohost/helpers

ynh_backup_dest (){
    YNH_CWD="${YNH_BACKUP_DIR%/}/$1"
    mkdir -p $YNH_CWD
    cd "$YNH_CWD"
}

# 在子命令错误或未设置变量时退出钩子
ynh_abort_if_errors

# Crontabs
ynh_backup_dest "conf/custom/crontabs"
ynh_backup "/var/spool/cron/crontabs"

# 其他(包括此文件)
ynh_backup_dest "conf/custom/misc"
ynh_backup "/etc/yunohost/hooks.d/backup/99-conf_custom"
ynh_backup "/etc/yunohost/hooks.d/restore/99-conf_custom"

分配适当的文件权限

这可能是不必要的,但我为了安全起见执行了这些操作。

chmod 740 /etc/yunohost/hooks.d/{backup,restore}/99-conf_custom

启动备份以查看钩子是否有效

对于 borg 来说,启动备份只需要简单执行 systemctl start borg

这些文件将包含在 _auto_conf 前缀的归档中,这将列出 ARCHIVE_NAME 中的文件:

app=borg; BORG_PASSPHRASE="$(yunohost app setting $app passphrase)" BORG_RSH="ssh -i /root/.ssh/id_${app}_CHANGE_THIS -oStrictHostKeyChecking=yes " borg list "$(yunohost app setting $app repository)::ARCHIVE_NAME | grep crontabs"