当前位置: 首页 > news >正文

《树莓派4B家庭服务器搭建指南》第二十期:在树莓派运行rsnapshot, 实现对服务器数据低成本增量本地备份


title: 020《树莓派4B家庭服务器搭建指南》第二十期:在树莓派运行rsnapshot, 实现对服务器数据低成本增量本地备份

我的天翼云服务器有/opt/usr/share/nginx两个目录, 用来存储网站的内容, 数据无价, 为了避免珍贵的数据丢失,我决定使用树莓派运行 rsnapshot, 为网站内容做定期备份。

为什么选择rsnapshot ?

  • rsnapshot是基于rsync的开源软件, 原理简单,无后门, 无需强制加密, 备份后的数据所见即所得
  • rsnapshot通过硬链接管理文件, 处于不同文件夹的同一个文件, 只占用一份存储空间, 节省磁盘
  • rsnapshot默认进行增量备份, 节省带宽。
  • rsnapshot长期维护(从2015年开始维护), 功能稳定,在Github的开源仓库https://github.com/rsnapshot/rsnapshot 有2.9k Star,广受好评

安装rsnapshot

 sudo apt install rsnapshot

image-20230817161316501

配置树莓派免密登录云服务器

cd ~/.ssh
ssh-keygen

image-20230817162637385

# 设置密钥权限 
# 公钥644
sudo chmod 644  ~/.ssh/fangyuanxiaozhan.com.pub
# 私钥600
sudo chmod 600  ~/.ssh/fangyuanxiaozhan.com

image-20230817163241171

将公钥发送的远程主机

ssh-copy-id -i ~/.ssh/fangyuanxiaozhan.com.pub 远程主机用户名@远程主机ip或域名

image-20230817164729349

在树莓派创建 ~/.ssh/config 并给与权限600

# 如果已经存在~/.ssh/config 则无需创建
touch ~/.ssh/config
chmod 600 ~/.ssh/config

~/.ssh/config 中填入以下内容

Host 主机ip或域名
HostName 主机ip或域名
User root
IdentityFile ~/.ssh/fangyuanxiaozhan.com

image-20230817164556148

ssh可以免密登录,基于rsync的rsnapshot也可以免密从服务器传输文件了。

按需求修改配置文件

  • 在树莓派创建rsnapshot备份文件夹
# 创建rsnapshot存储数据的根目录
mkdir /opt/rsnapshot
# 创建存储我天翼云服务器数据的目录
mkdir /opt/rsnapshot/CTYun
  • 设置根目录
    修改rsnapshot配置文件/etc/rsnapshot.conf, 将snapshot_root 对应的字段修改为在树莓派创建的根目录
snapshot_root   /opt/rsnapshot/

配置文件配置行之间使用Tab填充,空格会报错,比如snapshot_root(这里用Tab填充)/opt/rsnapshot/

  • 屏蔽本机备份配置

查看/etc/rsnapshot.conf 的底部,我们可以看到很多backup开头的配置行,其中默认的几行,是对树莓派本机的几个目录备份,可以前面添加#屏蔽掉

image-20230817184148071

  • 移除对ssh绝对路径的注释

由于rsnapshot从服务器备份数据依赖了rsync,而rsync又依赖了ssh,所以我们需要将ssh的绝对路径告诉rsnapshot, 也就是将cmd_ssh 所在行开头的#去掉

cmd_ssh /usr/bin/ssh
  • 改变锁文件的位置

lockfile的作用是防止同时运行两个rsnapshot实例,相当于一把锁,这把锁的位置可以由我们自己定义,lockfile的默认位置为/var/run/rsnapshot.pid ,我想以用户名ubuntu的身份运行rsnapshot实例,就要把锁文件位置配置到 ubuntu用户有权限修改的位置,我的处理方式是,新建 /home/ubuntu/.rsnapshot 文件夹

mkdir /home/ubuntu/.rsnapshot

然后将lockfile改为

lockfile /home/ubuntu/.rsnapshot/rsnapshot.pid
  • 备份文件夹的配置

在配置文件尾部追加

# CTYun
backup  root@fangyuanxiaozhan.com:/etc/nginx    ./
backup  root@fangyuanxiaozhan.com:/opt  ./      exclude=/opt/before,exclude=/opt/EasyTypora/node_modules
backup  root@fangyuanxiaozhan.com:/usr/share/nginx/fangyuanxiaozhan.com ./

测试配置文件格式是否正确

rsnapshot configtest

image-20230817191012225

我最终的配置文件(供参考)

#################################################
# rsnapshot.conf - rsnapshot configuration file #
#################################################
#                                               #
# PLEASE BE AWARE OF THE FOLLOWING RULE:        #
#                                               #
# This file requires tabs between elements      #
#                                               #
########################################################################
# CONFIG FILE VERSION #
#######################config_version  1.2###########################
# SNAPSHOT ROOT DIRECTORY #
############################ All snapshots will be stored under this root directory.
#
snapshot_root   /opt/rsnapshot/CTYun/# If no_create_root is enabled, rsnapshot will not automatically create the
# snapshot_root directory. This is particularly useful if you are backing
# up to removable media, such as a FireWire or USB drive.
#
#no_create_root 1#################################
# EXTERNAL PROGRAM DEPENDENCIES #
################################## LINUX USERS:   Be sure to uncomment "cmd_cp". This gives you extra features.
# EVERYONE ELSE: Leave "cmd_cp" commented out for compatibility.
#
# See the README file or the man page for more details.
#
cmd_cp          /bin/cp# uncomment this to use the rm program instead of the built-in perl routine.
#
cmd_rm          /bin/rm# rsync must be enabled for anything to work. This is the only command that
# must be enabled.
#
cmd_rsync       /usr/bin/rsync# Uncomment this to enable remote ssh backups over rsync.
#
cmd_ssh /usr/bin/ssh# Comment this out to disable syslog support.
#
cmd_logger      /usr/bin/logger# Uncomment this to specify the path to "du" for disk usage checks.
# If you have an older version of "du", you may also want to check the
# "du_args" parameter below.
#
#cmd_du         /usr/bin/du# Uncomment this to specify the path to rsnapshot-diff.
#
#cmd_rsnapshot_diff     /usr/bin/rsnapshot-diff# Specify the path to a script (and any optional arguments) to run right
# before rsnapshot syncs files
#
#cmd_preexec    /path/to/preexec/script# Specify the path to a script (and any optional arguments) to run right
# after rsnapshot syncs files
#
#cmd_postexec   /path/to/postexec/script# Paths to lvcreate, lvremove, mount and umount commands, for use with
# Linux LVMs.
#
#linux_lvm_cmd_lvcreate /sbin/lvcreate
#linux_lvm_cmd_lvremove /sbin/lvremove
#linux_lvm_cmd_mount    /bin/mount
#linux_lvm_cmd_umount   /bin/umount#########################################
#     BACKUP LEVELS / INTERVALS         #
# Must be unique and in ascending order #
# e.g. alpha, beta, gamma, etc.         #
#########################################retain  alpha   6
retain  beta    7
retain  gamma   4
#retain delta   3############################################
#              GLOBAL OPTIONS              #
# All are optional, with sensible defaults #
############################################# Verbose level, 1 through 5.
# 1     Quiet           Print fatal errors only
# 2     Default         Print errors and warnings only
# 3     Verbose         Show equivalent shell commands being executed
# 4     Extra Verbose   Show extra verbose information
# 5     Debug mode      Everything
#
verbose         2# Same as "verbose" above, but controls the amount of data sent to the
# logfile, if one is being used. The default is 3.
# If you want the rsync output, you have to set it to 4
#
loglevel        3# If you enable this, data will be written to the file you specify. The
# amount of data written is controlled by the "loglevel" parameter.
#
#logfile        /var/log/rsnapshot.log# If enabled, rsnapshot will write a lockfile to prevent two instances
# from running simultaneously (and messing up the snapshot_root).
# If you enable this, make sure the lockfile directory is not world
# writable. Otherwise anyone can prevent the program from running.
#
lockfile        /home/ubuntu/.rsnapshot/rsnapshot.pid# By default, rsnapshot check lockfile, check if PID is running
# and if not, consider lockfile as stale, then start
# Enabling this stop rsnapshot if PID in lockfile is not running
#
#stop_on_stale_lockfile         0# Default rsync args. All rsync commands have at least these options set.
#
#rsync_short_args       -a
#rsync_long_args        --delete --numeric-ids --relative --delete-excluded# ssh has no args passed by default, but you can specify some here.
#
#ssh_args       -p 22# Default arguments for the "du" program (for disk space reporting).
# The GNU version of "du" is preferred. See the man page for more details.
# If your version of "du" doesn't support the -h flag, try -k flag instead.
#
#du_args        -csh# If this is enabled, rsync won't span filesystem partitions within a
# backup point. This essentially passes the -x option to rsync.
# The default is 0 (off).
#
#one_fs         0# The include and exclude parameters, if enabled, simply get passed directly
# to rsync. If you have multiple include/exclude patterns, put each one on a
# separate line. Please look up the --include and --exclude options in the
# rsync man page for more details on how to specify file name patterns.
#
#include        ???
#include        ???
#exclude        ???
#exclude        ???# The include_file and exclude_file parameters, if enabled, simply get
# passed directly to rsync. Please look up the --include-from and
# --exclude-from options in the rsync man page for more details.
#
#include_file   /path/to/include/file
#exclude_file   /path/to/exclude/file# If your version of rsync supports --link-dest, consider enabling this.
# This is the best way to support special files (FIFOs, etc) cross-platform.
# The default is 0 (off).
#
#link_dest      0# When sync_first is enabled, it changes the default behaviour of rsnapshot.
# Normally, when rsnapshot is called with its lowest interval
# (i.e.: "rsnapshot alpha"), it will sync files AND rotate the lowest
# intervals. With sync_first enabled, "rsnapshot sync" handles the file sync,
# and all interval calls simply rotate files. See the man page for more
# details. The default is 0 (off).
#
#sync_first     0# If enabled, rsnapshot will move the oldest directory for each interval
# to [interval_name].delete, then it will remove the lockfile and delete
# that directory just before it exits. The default is 0 (off).
#
#use_lazy_deletes       0# Number of rsync re-tries. If you experience any network problems or
# network card issues that tend to cause ssh to fail with errors like
# "Corrupted MAC on input", for example, set this to a non-zero value
# to have the rsync operation re-tried.
#
#rsync_numtries 0# LVM parameters. Used to backup with creating lvm snapshot before backup
# and removing it after. This should ensure consistency of data in some special
# cases
#
# LVM snapshot(s) size (lvcreate --size option).
#
#linux_lvm_snapshotsize 100M# Name to be used when creating the LVM logical volume snapshot(s).
#
#linux_lvm_snapshotname rsnapshot# Path to the LVM Volume Groups.
#
#linux_lvm_vgpath       /dev# Mount point to use to temporarily mount the snapshot(s).
#
#linux_lvm_mountpath    /path/to/mount/lvm/snapshot/during/backup###############################
### BACKUP POINTS / SCRIPTS ###
################################ LOCALHOST
#backup /home/          localhost/
#backup /etc/           localhost/
#backup /usr/local/     localhost/
#backup /var/log/rsnapshot              localhost/
#backup /etc/passwd     localhost/
#backup /home/foo/My Documents/         localhost/
#backup /foo/bar/       localhost/      one_fs=1,rsync_short_args=-urltvpog
#backup_script  /usr/local/bin/backup_pgsql.sh  localhost/postgres/
# You must set linux_lvm_* parameters below before using lvm snapshots
#backup lvm://vg0/xen-home/     lvm-vg0/xen-home/# EXAMPLE.COM
#backup_exec    /bin/date "+ backup of example.com started at %c"
#backup root@example.com:/home/ example.com/    +rsync_long_args=--bwlimit=16,exclude=core
#backup root@example.com:/etc/  example.com/    exclude=mtab,exclude=core
#backup_exec    ssh root@example.com "mysqldump -A > /var/db/dump/mysql.sql"
#backup root@example.com:/var/db/dump/  example.com/
#backup_exec    /bin/date "+ backup of example.com ended at %c"# CVS.SOURCEFORGE.NET
#backup_script  /usr/local/bin/backup_rsnapshot_cvsroot.sh      rsnapshot.cvs.sourceforge.net/# RSYNC.SAMBA.ORG
#backup rsync://rsync.samba.org/rsyncftp/       rsync.samba.org/rsyncftp/
# CTYun
backup  root@fangyuanxiaozhan.com:/etc/nginx    ./
backup  root@fangyuanxiaozhan.com:/opt  ./      exclude=/opt/before,exclude=/opt/EasyTypora/node_modules
backup  root@fangyuanxiaozhan.com:/usr/share/nginx/fangyuanxiaozhan.com ./

配置行内的空余部分,不要用空格,一定要用Tab填充

  • 关于备份数量上限的解释

在以上配置文件中,有以下几行

retain  alpha   6
retain  beta    7
retain  gamma   4

以alpah为例, retain alpha 6代表最多进行六个备份,比如alpha.0 alpha.1 alpha.2 alpha.3 alpha.4 alpha.5 , 其中alpha.0为最新的备份,alpha.5为最老的备份,超过了6次备份,最早的一份将会从磁盘清除,首次运行备份指令后,alpha.0 文件夹会生成在根目录下面,也就是/opt/rsnapshot/CTYun/alpha.0, /opt/rsnapshot/CTYun/alpha.0文件夹里存放着备份好的文件目录。

  • 手动进行备份
rsnapshot -c /etc/rsnapshot.conf alpha

上面命令汇总,我们使用alpha策略进行备份,并指定了配置文件的位置。

执行完成后,查看目录结构

image-20230818133222842

可以看到alpha.0成了真的的根目录。

我们多运行几次rsnapshot -c /etc/rsnapshot.conf alpha , 可以看到在/opt/rsnapshot/CTYun 文件夹下有几个并列的alpha.* 文件夹

image-20230818133341387

由于配置了retain alpha 6,无论我们运行多少次,alpha.*都不会超过六个

image-20230818140155944

自动化备份

crontab是一款可以创建定时任务的工具,我们可以在crontab中添加每四小时运行rsnapshot -c /etc/rsnapshot.conf alpha 的任务,这样就相当于每天执行了6次备份。

ubuntucrontab默认对所有用户进行了安装,所以我们无需sudo权限就能创建任务,操作方法如下, 打开cron表

crontab -e

首次打开可以选择编辑器,我选择了vim 打开,添加每四小时运行一次命令的配置

0 */4 * * * rsnapshot -c /etc/rsnapshot.conf alpha

image-20230818141456454

写入配置后,退出编辑器即可;

优化: 创建每日执行,保留31天的备份任务

我希望每天凌晨4点能生成新备份,保留31天,但又不希望和每隔4小时的的备份有冲突(两个任务共用logfile会相互影响)。

于是我新开一个配置文件/home/ubuntu/.rsnapshot/mouthly.conf, 添加retain monthly 31, 修改filelock 为lockfile /home/ubuntu/.rsnapshot/monthly.pid

这里的monthly 完全可以自定义,并没有特殊性,可以是monthly001monthly002, 只要运行命令时,对应即可。

内容为

#################################################
# rsnapshot.conf - rsnapshot configuration file #
#################################################
#                                               #
# PLEASE BE AWARE OF THE FOLLOWING RULE:        #
#                                               #
# This file requires tabs between elements      #
#                                               #
########################################################################
# CONFIG FILE VERSION #
#######################config_version  1.2###########################
# SNAPSHOT ROOT DIRECTORY #
############################ All snapshots will be stored under this root directory.
#
snapshot_root   /opt/rsnapshot/CTYun/# If no_create_root is enabled, rsnapshot will not automatically create the
# snapshot_root directory. This is particularly useful if you are backing
# up to removable media, such as a FireWire or USB drive.
#
#no_create_root 1#################################
# EXTERNAL PROGRAM DEPENDENCIES #
################################## LINUX USERS:   Be sure to uncomment "cmd_cp". This gives you extra features.
# EVERYONE ELSE: Leave "cmd_cp" commented out for compatibility.
#
# See the README file or the man page for more details.
#
cmd_cp          /bin/cp# uncomment this to use the rm program instead of the built-in perl routine.
#
cmd_rm          /bin/rm# rsync must be enabled for anything to work. This is the only command that
# must be enabled.
#
cmd_rsync       /usr/bin/rsync# Uncomment this to enable remote ssh backups over rsync.
#
cmd_ssh /usr/bin/ssh# Comment this out to disable syslog support.
#
cmd_logger      /usr/bin/logger# Uncomment this to specify the path to "du" for disk usage checks.
# If you have an older version of "du", you may also want to check the
# "du_args" parameter below.
#
#cmd_du         /usr/bin/du# Uncomment this to specify the path to rsnapshot-diff.
#
#cmd_rsnapshot_diff     /usr/bin/rsnapshot-diff# Specify the path to a script (and any optional arguments) to run right
# before rsnapshot syncs files
#
#cmd_preexec    /path/to/preexec/script# Specify the path to a script (and any optional arguments) to run right
# after rsnapshot syncs files
#
#cmd_postexec   /path/to/postexec/script# Paths to lvcreate, lvremove, mount and umount commands, for use with
# Linux LVMs.
#
#linux_lvm_cmd_lvcreate /sbin/lvcreate
#linux_lvm_cmd_lvremove /sbin/lvremove
#linux_lvm_cmd_mount    /bin/mount
#linux_lvm_cmd_umount   /bin/umount#########################################
#     BACKUP LEVELS / INTERVALS         #
# Must be unique and in ascending order #
# e.g. alpha, beta, gamma, etc.         #
#########################################retain	monthly	31
retain  alpha   6
retain  beta    7
retain  gamma   4
#retain delta   3############################################
#              GLOBAL OPTIONS              #
# All are optional, with sensible defaults #
############################################# Verbose level, 1 through 5.
# 1     Quiet           Print fatal errors only
# 2     Default         Print errors and warnings only
# 3     Verbose         Show equivalent shell commands being executed
# 4     Extra Verbose   Show extra verbose information
# 5     Debug mode      Everything
#
verbose         2# Same as "verbose" above, but controls the amount of data sent to the
# logfile, if one is being used. The default is 3.
# If you want the rsync output, you have to set it to 4
#
loglevel        3# If you enable this, data will be written to the file you specify. The
# amount of data written is controlled by the "loglevel" parameter.
#
#logfile        /var/log/rsnapshot.log# If enabled, rsnapshot will write a lockfile to prevent two instances
# from running simultaneously (and messing up the snapshot_root).
# If you enable this, make sure the lockfile directory is not world
# writable. Otherwise anyone can prevent the program from running.
#
lockfile        /home/ubuntu/.rsnapshot/monthly.pid# By default, rsnapshot check lockfile, check if PID is running
# and if not, consider lockfile as stale, then start
# Enabling this stop rsnapshot if PID in lockfile is not running
#
#stop_on_stale_lockfile         0# Default rsync args. All rsync commands have at least these options set.
#
#rsync_short_args       -a
#rsync_long_args        --delete --numeric-ids --relative --delete-excluded# ssh has no args passed by default, but you can specify some here.
#
#ssh_args       -p 22# Default arguments for the "du" program (for disk space reporting).
# The GNU version of "du" is preferred. See the man page for more details.
# If your version of "du" doesn't support the -h flag, try -k flag instead.
#
#du_args        -csh# If this is enabled, rsync won't span filesystem partitions within a
# backup point. This essentially passes the -x option to rsync.
# The default is 0 (off).
#
#one_fs         0# The include and exclude parameters, if enabled, simply get passed directly
# to rsync. If you have multiple include/exclude patterns, put each one on a
# separate line. Please look up the --include and --exclude options in the
# rsync man page for more details on how to specify file name patterns.
#
#include        ???
#include        ???
#exclude        ???
#exclude        ???# The include_file and exclude_file parameters, if enabled, simply get
# passed directly to rsync. Please look up the --include-from and
# --exclude-from options in the rsync man page for more details.
#
#include_file   /path/to/include/file
#exclude_file   /path/to/exclude/file# If your version of rsync supports --link-dest, consider enabling this.
# This is the best way to support special files (FIFOs, etc) cross-platform.
# The default is 0 (off).
#
#link_dest      0# When sync_first is enabled, it changes the default behaviour of rsnapshot.
# Normally, when rsnapshot is called with its lowest interval
# (i.e.: "rsnapshot alpha"), it will sync files AND rotate the lowest
# intervals. With sync_first enabled, "rsnapshot sync" handles the file sync,
# and all interval calls simply rotate files. See the man page for more
# details. The default is 0 (off).
#
#sync_first     0# If enabled, rsnapshot will move the oldest directory for each interval
# to [interval_name].delete, then it will remove the lockfile and delete
# that directory just before it exits. The default is 0 (off).
#
#use_lazy_deletes       0# Number of rsync re-tries. If you experience any network problems or
# network card issues that tend to cause ssh to fail with errors like
# "Corrupted MAC on input", for example, set this to a non-zero value
# to have the rsync operation re-tried.
#
#rsync_numtries 0# LVM parameters. Used to backup with creating lvm snapshot before backup
# and removing it after. This should ensure consistency of data in some special
# cases
#
# LVM snapshot(s) size (lvcreate --size option).
#
#linux_lvm_snapshotsize 100M# Name to be used when creating the LVM logical volume snapshot(s).
#
#linux_lvm_snapshotname rsnapshot# Path to the LVM Volume Groups.
#
#linux_lvm_vgpath       /dev# Mount point to use to temporarily mount the snapshot(s).
#
#linux_lvm_mountpath    /path/to/mount/lvm/snapshot/during/backup###############################
### BACKUP POINTS / SCRIPTS ###
################################ LOCALHOST
#backup /home/          localhost/
#backup /etc/           localhost/
#backup /usr/local/     localhost/
#backup /var/log/rsnapshot              localhost/
#backup /etc/passwd     localhost/
#backup /home/foo/My Documents/         localhost/
#backup /foo/bar/       localhost/      one_fs=1,rsync_short_args=-urltvpog
#backup_script  /usr/local/bin/backup_pgsql.sh  localhost/postgres/
# You must set linux_lvm_* parameters below before using lvm snapshots
#backup lvm://vg0/xen-home/     lvm-vg0/xen-home/# EXAMPLE.COM
#backup_exec    /bin/date "+ backup of example.com started at %c"
#backup root@example.com:/home/ example.com/    +rsync_long_args=--bwlimit=16,exclude=core
#backup root@example.com:/etc/  example.com/    exclude=mtab,exclude=core
#backup_exec    ssh root@example.com "mysqldump -A > /var/db/dump/mysql.sql"
#backup root@example.com:/var/db/dump/  example.com/
#backup_exec    /bin/date "+ backup of example.com ended at %c"# CVS.SOURCEFORGE.NET
#backup_script  /usr/local/bin/backup_rsnapshot_cvsroot.sh      rsnapshot.cvs.sourceforge.net/# RSYNC.SAMBA.ORG
#backup rsync://rsync.samba.org/rsyncftp/       rsync.samba.org/rsyncftp/
# CTYun
backup  root@fangyuanxiaozhan.com:/etc/nginx    ./
backup  root@fangyuanxiaozhan.com:/opt  ./      exclude=/opt/before,exclude=/opt/EasyTypora/node_modules
backup  root@fangyuanxiaozhan.com:/usr/share/nginx/fangyuanxiaozhan.com ./

测试月度备份配置文件

rsnapshot -c /home/ubuntu/.rsnapshot/monthly.conf configtest

image-20230818145242293

运行crontab -e ,将以下配置添加为每日凌晨四点运行的定时任务

0 4 * * * rsnapshot -c /home/ubuntu/.rsnapshot/monthly.conf monthly

monthly任务备份后,会产生以monthly开头的文件夹

rsnapshot -c /home/ubuntu/.rsnapshot/monthly.conf monthly

image-20230818150447397

小结

云服务商的硬盘还是蛮贵的,对于个人开发者而言,同时能省一些钱总是好的。

2023年的机械硬盘算是很便宜了,1千块能买16TB的全新盘,搞一块插到树莓派,定期对服务器数据做增量备份,成本比云服务商的低很多。

如果你是一个上班族,办公室和家里各部署一套rsnapshot备份,也算是支持数据分布式异地容灾了。

为什么要把服务器数据备份到本地?目前的ICP备案搞的风风火火,买了服务器,由于备案的限制,也不能马上使用80,443等端口,即使服务器备了案,解析的域名也会受到限制,如果有一天,由于某种不可抗力,把个人备案关联的服务器的数据全部封存,也不是不可能,所以,做好本地数据备份,总是没错的,反正成本也不高。

本文属于《树莓派不吃灰》系列的第二十期,《树莓派不吃灰》系列教程开源地址 github.com/zhaoolee/pi

本文永久更新地址(欢迎来读留言,写评论):

https://www.v2fy.com/p/2023-08-17-rsnapshot-1692258217000

相关文章:

《树莓派4B家庭服务器搭建指南》第二十期:在树莓派运行rsnapshot, 实现对服务器数据低成本增量本地备份

title: 020《树莓派4B家庭服务器搭建指南》第二十期:在树莓派运行rsnapshot, 实现对服务器数据低成本增量本地备份 我的天翼云服务器有/opt 和 /usr/share/nginx两个目录, 用来存储网站的内容, 数据无价, 为了避免珍贵的数据丢失,我决定使用树莓派运行 …...

大数据 算法

什么是大数据 大数据是指数据量巨大、类型繁多、处理速度快的数据集合。这些数据集合通常包括结构化数据(如数据库中的表格数据)、半结构化数据(如XML文件)和非结构化数据(如文本、音频和视频文件)。大数据…...

html | 基于iframe的简易富文本编辑器

效果图 支持: 选中后 ctrlI 斜体 代码 思路就是在iframe种嵌套html和css。 <pre> - 支持: 选中后 ctrlI 斜体 - todo: 鼠标实现单击斜体 </pre> <iframe name"richedit" style"height:30%; width:100%;"></iframe><script…...

HJ108 求最小公倍数

描述 正整数A和正整数B 的最小公倍数是指 能被A和B整除的最小的正整数值&#xff0c;设计一个算法&#xff0c;求输入A和B的最小公倍数。 数据范围&#xff1a;1≤a,b≤100000 1≤a,b≤100000 输入描述&#xff1a; 输入两个正整数A和B。 输出描述&#xff1a; 输出A和B…...

JVM - 垃圾收集器

目录 垃圾收集器 串行垃圾收集器 并行垃圾收集器 什么是 吞吐量优先 什么是 响应时间优先 &#xff1f; CMS&#xff08;并发&#xff09;垃圾收集器 G1 垃圾收集器 垃圾收集器 垃圾收集器大概可以分为&#xff1a; 串行垃圾收集器并行垃圾收集器CMS&#xff08;并发&a…...

华为数通方向HCIP-DataCom H12-821题库(单选题:21-40)

第21题 在广播类型网络中,DIS默认发送Hello时间间隔为多少? A、10s B、3.3s C、5S D、40s 答案&#xff1a;B 解析&#xff1a; 在广播环境中,DIS 发送 hello 报文的周期更加的短,是普通ISIS路由器的1/3,普通ISIS路由器发送hello的时间为10s,所以DIS发送hello的周期是3.3s …...

Springboot+mybaits-plus+h2集成产生的一些问题(not found tables)

一、问题描述 org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "EP_MAPPING" not found (this database is empty);大概就是说在引入mybatis-plus的依赖后&#xff0c;找不到数据库找不到表的问题。 排查方向&#xff1a;在引入mybatish2时&#xff0c;是可以正常…...

【C#学习笔记】C#特性的继承,封装,多态

文章目录 封装访问修饰符静态类和静态方法静态构造函数 继承继承原则sealed修饰符里氏替换原则继承中的构造函数 多态接口接口的实例化 抽象类和抽象方法抽象类和接口的异同 虚方法同名方法new覆盖的父类方法继承的同名方法 运行时的多态性编译时的多态性 照理继承封装多态应该…...

常用的电参数

电参数根据电流的特点可以分为直流电参数和交流电参数&#xff0c;在电参数中有些是可以通过电参数表测得&#xff0c;有些参数则为通过测得的参数计算而来。 一、电参数 1.1 直接可测电参数 ——瞬时电压值 ——瞬时电流值 n——采样点数 f——频率 time——时间 其中&…...

Rabbitmq的应用场景

Rabbitmq的应用场景 一、异步处理 场景说明&#xff1a;用户注册后&#xff0c;需要发注册邮件和注册短信,传统的做法有两种 1.串行的方式 2.并行的方式 ​​串行方式​​: 将注册信息写入数据库后,发送注册邮件,再发送注册短信,以上三个任务全部完成后才返回给客户端。 这有…...

【CSS动画08--流光按钮】

CSS动画08--流光按钮 介绍HTMLCSS 介绍 流光button HTML <!DOCTYPE html> <html><head><meta http-equiv"content-type" content"text/html; charsetutf-8"><meta name"viewport" content"widthdevice-width,i…...

计算机视觉:比SAM快50倍的分割一切视觉模型FastSAM

目录 引言 1 FastSAM介绍 1.1 FastSAM诞生 1.2 模型算法 1.3 实验结果 2 FastSAM运行环境构建 2.1 conda环境构建 2.2 运行环境安装 2.3 模型下载 3 FastSAM运行 3.1 命令行运行 3.1.1 Everything mode 3.1.2 Text prompt 3.1.3 Box prompt (xywh) 3.1.4 Points p…...

【官方中文文档】Mybatis-Spring #目录

目录 此页面用于在GitHub上呈现索引。 NOTE: 由于链接目标是在使用maven-site-plugin转换为html的假设下指定的&#xff0c;因此在GitHub上的呈现中有一个锚点已损坏。 简介入门SqlSessionFactoryBean事务使用 SqlSession注入映射器Spring Boot使用 MyBatis APISpring Batch示…...

ardupilot开发 --- Lua脚本篇

概述 ArduPilot引入了对Lua脚本的支持&#xff1b; Lua脚本存放在 SD card 中&#xff1b; Copter-4.0 及以上版本才支持Lua脚本&#xff1b; scripting API &#xff1f; scripting applets &#xff1f; 飞控条件&#xff1a;2 MB of flash and 70 kB of memory &#xff1b…...

python35种绘图函数总结,3D、统计、流场,实用性拉满

文章目录 基础图误差线三维图等高线图场图统计图非结构坐标图 基础图 下面这8种图像一般只有两组坐标&#xff0c;直观容易理解。 函数坐标参数图形类别plotx,y曲线图stackplotx,y散点图stemx,y茎叶图scatterx,y散点图polarx,y极坐标图stepx,y步阶图barx,y条形图barhx,y横向条…...

shell脚本语句(画矩形、三角形、乘法表和小游戏)(#^.^#)

目录 一、语句 一、条件语句 一、以用户为例演示 一、显示当前登录系统的用户信息 二、显示有多少个用户 二、单分支if 一、输入脚本 二、验证结果 三、双分支if 一、输入脚本 二、验证结果 四、多分支if 一、输入脚本 二、验证 二、循环语句 一、shell版本的循环…...

vue3、react组件数据传值对比分析——父组件传递子组件,子组件传递父组件

文章目录 ⭐前言⭐react 组件传值实例&#x1f496;父组件传值给子组件&#xff08;props&#xff09;&#x1f496;子组件传递事件给父组件props绑定事件&#x1f496;父组件触发子组件的事件Ref ⭐vue3 组件传值实例&#x1f496; 父组件传递数据给子组件props&#x1f496; …...

2023国赛数学建模C题思路模型代码 高教社杯

本次比赛我们将会全程更新思路模型及代码&#xff0c;大家查看文末名片获取 之前国赛相关的资料和助攻可以查看 2022数学建模国赛C题思路分析_2022国赛c题matlab_UST数模社_的博客-CSDN博客 2022国赛数学建模A题B题C题D题资料思路汇总 高教社杯_2022国赛c题matlab_UST数模社…...

wxPython使用matplotlib绘制动态曲线

1.思路 我们创建了一个继承自wx.Frame的自定义窗口类MyFrame。在MyFrame的构造函数中&#xff0c;我们创建了一个matplotlib的Figure对象和一个FigureCanvas对象&#xff0c;用于在窗口中显示绘图结果。然后&#xff0c;我们使用numpy生成了一个包含100个点的x轴坐标数组self.…...

JVM——类的生命周期

文章目录 类加载过程加载验证准备解析初始化 卸载 一个类的完整生命周期如下&#xff1a; 类加载过程 Class 文件需要加载到虚拟机中之后才能运行和使用&#xff0c;那么虚拟机是如何加载这些 Class 文件呢&#xff1f; 系统加载 Class 类型的文件主要三步:加载->连接->…...

【Docker】docker数据卷(数据挂载)持久化

docker数据卷&#xff08;数据挂载&#xff09;持久化 一、docker对于数据的管理二、docker挂载主机目录---指定路径挂载三、docker使用数据卷Volume挂载四、数据共享--数据卷容器五、备份和恢复 docker的镜像是由多个只读的文件系统叠加在一起形成的。当我们在我启动一个容器的…...

Spring Boot实现IP地址解析

一、本地解析 如果使用本地ip解析的话&#xff0c;我们将会借助ip2region&#xff0c;该项目维护了一份较为详细的本地ip地址对应表&#xff0c;如果为了离线环境的使用&#xff0c;需要导入该项目依赖&#xff0c;并指定版本&#xff0c;不同版本的方法可能存在差异。 <d…...

小程序中通过canvas生成并保存图片

1. html <canvas class"canvas" id"photo" type"2d" style"width:200px;height: 300px;"></canvas> <button bindtap"saveImage">保存</button> <!-- 用来展示生成的那张图片 --> <image…...

Error creating bean with name ‘esUtils‘ defined in file

报错异常&#xff1a; 背景&#xff1a; esUtils在common服务中、启动media服务时候、报这个异常、后排查esUtils在启动时候发生异常引起的、在相关bean中加入try{}catch{}即可解决问题 String[] split url.split(","); HttpHost[] httpHosts new HttpHost[split.…...

Java开发面试题 | 2023

Java基础 接口和抽象类的区别&#xff1f;Java动态代理HashMap 底层实现及put元素的具体过程currenthashmap底层实现原理&#xff1f;map可以放null值吗&#xff0c;currenthashmap为什么不能放null值synchronze和reetrantlock区别&#xff1f;怎样停止一个运行中的线程&#…...

Java课题笔记~ 自定义拦截器实现权限验证

实现一个权限验证拦截器。 1、修改web.xml文件中请求路径 2、将所有的页面放入WEB-INF目录下 3、开发登录FirstController 4、开发拦截器 5、配置springmvc.xml文件 <?xml version"1.0" encoding"UTF-8"?> <beans xmlns"http://www.spri…...

微信小程序使用npm引入三方包详解

目录 1 前言2 微信小程序npm环境搭建2.1 创建package.json文件2.2 修改 project.config.json2.3 修改project.private.config.json配置2.4 构建 npm 包2.5 typescript 支持2.6 安装组件2.7 引入使用组件 1 前言 从小程序基础库版本 2.2.1 或以上、及开发者工具 1.02.1808300 或…...

pytest自动化框架运行全局配置文件pytest.ini

还记得在之前的篇章中有讲到Pytest是目前主要流行的自动化框架之一&#xff0c;他有基础的脚本编码规则以及两种运行方式。 pytest的基础编码规则是可以进行修改&#xff0c;这就是今日文章重点。 看到这大家心中是否提出了两个问题&#xff1a;pytest的基础编码规则在哪可以…...

视频播放实现示例Demo

学习链接 vuespringboot文件分片上传与边放边播实现 同步加载、播放视频的实现 ---- range blob mediaSource 通过调试技术&#xff0c;我理清了 b 站视频播放很快的原理 MSE (Media Source Extensions) 上手指南 浅聊音视频的媒体扩展&#xff08;Media Source Extension…...

makefile的自动化变量

一、是什么? 自动化变量:makefile依据执行的规则自动变化生成的变量 $(@) 规则的目标文件名 $(^) 所有依赖 依赖列表 $(<)第一个依赖文件名 $(*)规则中目标中%部分名 $(?)所有比目标文件更新的依赖文件列表,空格分隔 二、使用步骤 1.引入库 代码如下(示例): make …...

使用Kind搭建本地k8s集群环境

目录 1.前提条件 2.安装Kind 3.使用Kind创建一个K8s集群 3.1.创建一个双节点集群&#xff08;一个Master节点&#xff0c;一个Worker节点&#xff09; 3.2.验证一下新创建的集群信息 3.3.删除刚刚新建的集群 4.安装集群客户端 4.1.安装kubectl 4.1.1.验证kubectl 4.2.安…...

【STM32RT-Thread零基础入门】 7. 线程创建应用(多线程运行机制)

硬件&#xff1a;STM32F103ZET6、ST-LINK、usb转串口工具、4个LED灯、1个蜂鸣器、4个1k电阻、2个按键、面包板、杜邦线 文章目录 前言一、RT-Thread相关接口函数1. 获取当前运行的线程2. 设置调度器钩子函数 二、程序设计1. 头文件包含及宏定义2. 线程入口函数定义3. main函数设…...

.net日志系统

.NET 平台提供了强大的日志记录系统,用于在应用程序中记录各种事件、错误和调试信息。最常用的日志记录库是 Microsoft.Extensions.Logging,它是一个通用的日志接口和基础框架,可以与多种日志实现集成。以下是如何使用 .NET 日志系统的基本步骤: 安装 NuGet 包:首先,您需…...

SpringCloud学习笔记(二)_Eureka注册中心

一、Eureka简介 Eureka是一项基于REST&#xff08;代表性状态转移&#xff09;的服务&#xff0c;主要在AWS云中用于定位服务&#xff0c;以实现负载均衡和中间层服务器的故障转移。我们称此服务为Eureka Server。Eureka还带有一个基于Java的客户端组件Eureka Client&#xff…...

spark的eventLog日志分析

查找满足指定条件的app_id查询条件: 表名、时间、节点名时间限定: 最好适当放大, 不知道什么原因有点不准eventLog的存放路径: spark.history.fs.logDirectory 1. spark-sql 先限定时间段;数据是逐行读入的, 但 app_id要按整个文件过滤, 按每个条件打标;按app_id粒度聚合, 查…...

探究Java spring中jdk代理和cglib代理!

面对新鲜事物&#xff0c;我们要先了解在去探索事物的本质-默 目录 一.介绍二者代理模式 1.1.Jdk代理模式 1.2cglib代理模式 1.3二者区别 1.3.1有无接口 1.3.2灵活性 1.4对于两种代理模式的总结 1.4.1jdk代理模式 1.4.2cglib代理模式 二.两种代理模式应用场景 2.1jd…...

反转链表(C++)

1、迭代法的一种写法 ListNode* reverse_linkList(ListNode* head){if(head nullptr || head->next nullptr) return head;ListNode* begin nullptr;ListNode* mid head;ListNode* end head->next;while(true){mid->next begin;if(end nullptr){break;}begin …...

适配器模式:让不兼容的接口协同工作

在面向对象设计中&#xff0c;适配器模式是一种常见的结构型设计模式。它允许将不兼容的接口转换成客户端所期望的另一个接口&#xff0c;从而使不同的类协同工作。适配器模式的主要目的是解决不同接口之间的兼容性问题&#xff0c;同时也提高了代码的可重用性和灵活性。 问题…...

【1day】复现Milesight-VPNserver.js 任意文件读取漏洞

目录 一、漏洞描述 二、影响版本 三、资产测绘 四、漏洞复现 一、漏洞描述 Milesight路由器-VPN是由Milesight Technology Co., Ltd.开发的一种集成了VPN功能的路由器产品。它旨在为用户提供安全、可靠的远程访问和连接解决方案。Milesight-VPNserver.js存在任意文件读取…...

前端代码规范

1 husky husky用于绑定git hooks&#xff0c;在指定时机执行想要的命令 {"husky": {"hooks": {"pre-commit": "lint-staged" }} }需要手动修改.husky文件内容&#xff1a; . "$(dirname -- "$0")/_/husky.sh"n…...

Java接入文心一言

文章目录 文心一言应用创建接口对接接口文档代码示例依赖 常量类实体类 结束语 文心一言应用创建 首先需要先申请文心千帆大模型&#xff0c;申请地址&#xff1a;文心一言 (baidu.com)&#xff0c;点击加入体验&#xff0c;等通过审核之后就可以进入文心千帆大模型后台进行应…...

信息管理系统三级等保的一些要求

一、前言 在做一些互联网系统或面向互联网的系统时&#xff0c;需要进行备案&#xff0c;需要满足网络信息安全维护规章及有关规章制度要求&#xff0c;才能发布到互联网。所以在做系统的需求分析时&#xff0c;往往需要把信息管理系统三级等保的需求加上&#xff0c;方便开发…...

第六届“蓝帽杯”电子取证模块(初赛)解析+全资源一次性分享

前言:资源一次性分享 手机+电脑+exe+内存四个模块,我自己在网上也找了很久,才把资源找齐全,题目我也整理在这里,方便大家训练。 目录...

《Go 语言第一课》课程学习笔记(九)

常量&#xff1a;Go 在“常量”设计上的创新有哪些&#xff1f; Go 语言在常量方面的创新包括下面这几点&#xff1a; 支持无类型常量&#xff1b;支持隐式自动转型&#xff1b;可用于实现枚举。 常量 Go 语言的常量是一种在源码编译期间被创建的语法元素。这是在说这个元素…...

docker 安装nginx 和 elasticsearch ik 自定义分词

1、切换到/mydata 文件夹 创建 nginx 目录 mkdir nginx 2、运行 docker run --name nginx -p 80:80 -d nginx:1.22.0 3、复制docker 里面的nginx配置到 外面的nginx/conf 下面 docker cp nginx:/etc/nginx /mydata/nginx 4、把 /mydata/nginx下面的nginx 改…...

谈谈收音机的发展

目录 1.什么是收音机 2.收音机的工作原理 3.收音机的发展历史 4.收音机的历史作用 1.什么是收音机 收音机是一种电子设备&#xff0c;用于接收和播放广播电台的无线电信号。它是人们获取各种音乐、新闻、娱乐和其他广播节目的常用设备。 收音机通常由以下几个部分组成&…...

QTreeWidget——信号处理

文章目录 基本属性信号一、信号种类二、信号测试1、currentItemChanged、itemCollapsed、itemExpanded三个信号的测试2、itemActivated信号3、 itemChanged信号4、其余信号的测试代码&#xff08;包含以上代码&#xff09; 基本属性 信号 一、信号种类 //当前项发生变化时触…...

【Java从入门到精通|1】从特点到第一个Hello World程序

写在前面 在计算机编程领域&#xff0c;Java是一门广泛应用的高级编程语言。它以其强大的跨平台性能、丰富的库和生态系统以及易于学习的语法而备受开发者欢迎。本文将引导您逐步了解Java的特点、如何安装和配置开发环境&#xff0c;以及如何编写您的第一个Java程序。 一、Java…...

JAVA 读取jar包中excel模板

1、在resources路径下&#xff0c;新建report文件夹&#xff0c;放入excel模板 2、配置文件中的目录&#xff0c;分隔符使用 / template: /report/报告模板V1.0.xlsx3、使用getResourceAsStream()读取 XSSFWorkbook wb;try {//需要以/开始InputStream resourceAsStream this.g…...

解决方案:fatal error: openssl/bio.h: 没有那个文件或目录

出现报错如下&#xff1a; 出现该错误的原因有两个&#xff1a; 没有安装openssl或者libssl-dev库Libssl-dev版本过高&#xff0c;需要降级 一. 没有安装openssl或者libssl-dev库 使用指令安装openssl&#xff1a; 我的是已经安装完成了&#xff0c;所以再把libssl-dev的库也…...