dokuwiki自动备份设置

设置坚果云

账户信息” > “安全选项

安装cadaver客户端

1、安装cadaver

1
apt install cadaver

2、使用cadaver连接webdav服务器

1
2
3
4
5
6
7
8
9
cadaver   https://dav.jianguoyun.com/dav/
Authentication required for nutstore on server `dav.jianguoyun.com':
Username: ******** #你的坚果云账户
Password: ******** #你的应用密码
dav:/dav/> ls
Listing collection `/dav/': succeeded.
Coll: backup 0 Sep 22 16:54
*#使用put命令上传文件,使用get命令下载文件,类似于ftp命令行;*
*#使用help命令帮助。*

3、配置非交互式登录

1
2
3
4
vim  .netrc
machine dav.jianguoyun.com
login ********* #你的坚果云账户
password ******** #你的应用密码

设置备份脚本

参考博客 http://sunyongfeng.com/201704/linux/execute_scheduled_commands.html

1、创建脚本

1
2
3
4
5
6
7
8
9
#!/bin/bash

backpath=/var/www/backup
date=`date +%y%m%d`
site='wiki'
tar zcf ${backpath}${site}"-"${date}.tar.gz /var/www/html/
cadaver https://dav.jianguoyun.com/dav/backup/ <<E
put ${backpath}${site}-${date}.tar.gz
E

2、设置Linux定时任务

1
2
root@ubuntu:~# export EDITOR=vim 
root@ubuntu:~# crontab -e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
no crontab for root - using an empty one
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
30 04 * * * /root/dokuwiki.backup.sh