国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份

這篇具有很好參考價(jià)值的文章主要介紹了《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。


title: 020《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份

我的天翼云服務(wù)器有/opt/usr/share/nginx兩個(gè)目錄, 用來存儲(chǔ)網(wǎng)站的內(nèi)容, 數(shù)據(jù)無價(jià), 為了避免珍貴的數(shù)據(jù)丟失,我決定使用樹莓派運(yùn)行 rsnapshot, 為網(wǎng)站內(nèi)容做定期備份。

為什么選擇rsnapshot ?

  • rsnapshot是基于rsync的開源軟件, 原理簡單,無后門, 無需強(qiáng)制加密, 備份后的數(shù)據(jù)所見即所得
  • rsnapshot通過硬鏈接管理文件, 處于不同文件夾的同一個(gè)文件, 只占用一份存儲(chǔ)空間, 節(jié)省磁盤
  • rsnapshot默認(rèn)進(jìn)行增量備份, 節(jié)省帶寬。
  • rsnapshot長期維護(hù)(從2015年開始維護(hù)), 功能穩(wěn)定,在Github的開源倉庫https://github.com/rsnapshot/rsnapshot 有2.9k Star,廣受好評(píng)

安裝rsnapshot

 sudo apt install rsnapshot

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

配置樹莓派免密登錄云服務(wù)器

cd ~/.ssh
ssh-keygen

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

# 設(shè)置密鑰權(quán)限 
# 公鑰644
sudo chmod 644  ~/.ssh/fangyuanxiaozhan.com.pub
# 私鑰600
sudo chmod 600  ~/.ssh/fangyuanxiaozhan.com

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

將公鑰發(fā)送的遠(yuǎn)程主機(jī)

ssh-copy-id -i ~/.ssh/fangyuanxiaozhan.com.pub 遠(yuǎn)程主機(jī)用戶名@遠(yuǎn)程主機(jī)ip或域名

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

在樹莓派創(chuàng)建 ~/.ssh/config 并給與權(quán)限600

# 如果已經(jīng)存在~/.ssh/config 則無需創(chuàng)建
touch ~/.ssh/config
chmod 600 ~/.ssh/config

~/.ssh/config 中填入以下內(nèi)容

Host 主機(jī)ip或域名
HostName 主機(jī)ip或域名
User root
IdentityFile ~/.ssh/fangyuanxiaozhan.com

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

ssh可以免密登錄,基于rsync的rsnapshot也可以免密從服務(wù)器傳輸文件了。

按需求修改配置文件

  • 在樹莓派創(chuàng)建rsnapshot備份文件夾
# 創(chuàng)建rsnapshot存儲(chǔ)數(shù)據(jù)的根目錄
mkdir /opt/rsnapshot
# 創(chuàng)建存儲(chǔ)我天翼云服務(wù)器數(shù)據(jù)的目錄
mkdir /opt/rsnapshot/CTYun
  • 設(shè)置根目錄
    修改rsnapshot配置文件/etc/rsnapshot.conf, 將snapshot_root 對(duì)應(yīng)的字段修改為在樹莓派創(chuàng)建的根目錄
snapshot_root   /opt/rsnapshot/

配置文件配置行之間使用Tab填充,空格會(huì)報(bào)錯(cuò),比如snapshot_root(這里用Tab填充)/opt/rsnapshot/

  • 屏蔽本機(jī)備份配置

查看/etc/rsnapshot.conf 的底部,我們可以看到很多backup開頭的配置行,其中默認(rèn)的幾行,是對(duì)樹莓派本機(jī)的幾個(gè)目錄備份,可以前面添加#屏蔽掉

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

  • 移除對(duì)ssh絕對(duì)路徑的注釋

由于rsnapshot從服務(wù)器備份數(shù)據(jù)依賴了rsync,而rsync又依賴了ssh,所以我們需要將ssh的絕對(duì)路徑告訴rsnapshot, 也就是將cmd_ssh 所在行開頭的#去掉

cmd_ssh /usr/bin/ssh
  • 改變鎖文件的位置

lockfile的作用是防止同時(shí)運(yùn)行兩個(gè)rsnapshot實(shí)例,相當(dāng)于一把鎖,這把鎖的位置可以由我們自己定義,lockfile的默認(rèn)位置為/var/run/rsnapshot.pid ,我想以用戶名ubuntu的身份運(yùn)行rsnapshot實(shí)例,就要把鎖文件位置配置到 ubuntu用戶有權(quán)限修改的位置,我的處理方式是,新建 /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

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

我最終的配置文件(供參考)

#################################################
# 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 ./

配置行內(nèi)的空余部分,不要用空格,一定要用Tab填充

  • 關(guān)于備份數(shù)量上限的解釋

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

retain  alpha   6
retain  beta    7
retain  gamma   4

以alpah為例, retain alpha 6代表最多進(jìn)行六個(gè)備份,比如alpha.0 alpha.1 alpha.2 alpha.3 alpha.4 alpha.5 , 其中alpha.0為最新的備份,alpha.5為最老的備份,超過了6次備份,最早的一份將會(huì)從磁盤清除,首次運(yùn)行備份指令后,alpha.0 文件夾會(huì)生成在根目錄下面,也就是/opt/rsnapshot/CTYun/alpha.0, /opt/rsnapshot/CTYun/alpha.0文件夾里存放著備份好的文件目錄。

  • 手動(dòng)進(jìn)行備份
rsnapshot -c /etc/rsnapshot.conf alpha

上面命令匯總,我們使用alpha策略進(jìn)行備份,并指定了配置文件的位置。

執(zhí)行完成后,查看目錄結(jié)構(gòu)

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

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

我們多運(yùn)行幾次rsnapshot -c /etc/rsnapshot.conf alpha , 可以看到在/opt/rsnapshot/CTYun 文件夾下有幾個(gè)并列的alpha.* 文件夾

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

由于配置了retain alpha 6,無論我們運(yùn)行多少次,alpha.*都不會(huì)超過六個(gè)

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

自動(dòng)化備份

crontab是一款可以創(chuàng)建定時(shí)任務(wù)的工具,我們可以在crontab中添加每四小時(shí)運(yùn)行rsnapshot -c /etc/rsnapshot.conf alpha 的任務(wù),這樣就相當(dāng)于每天執(zhí)行了6次備份。

ubuntucrontab默認(rèn)對(duì)所有用戶進(jìn)行了安裝,所以我們無需sudo權(quán)限就能創(chuàng)建任務(wù),操作方法如下, 打開cron表

crontab -e

首次打開可以選擇編輯器,我選擇了vim 打開,添加每四小時(shí)運(yùn)行一次命令的配置

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

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

寫入配置后,退出編輯器即可;

優(yōu)化: 創(chuàng)建每日?qǐng)?zhí)行,保留31天的備份任務(wù)

我希望每天凌晨4點(diǎn)能生成新備份,保留31天,但又不希望和每隔4小時(shí)的的備份有沖突(兩個(gè)任務(wù)共用logfile會(huì)相互影響)。

于是我新開一個(gè)配置文件/home/ubuntu/.rsnapshot/mouthly.conf, 添加retain monthly 31, 修改filelock 為lockfile /home/ubuntu/.rsnapshot/monthly.pid

這里的monthly 完全可以自定義,并沒有特殊性,可以是monthly001monthly002, 只要運(yùn)行命令時(shí),對(duì)應(yīng)即可。

內(nèi)容為

#################################################
# 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

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

運(yùn)行crontab -e ,將以下配置添加為每日凌晨四點(diǎn)運(yùn)行的定時(shí)任務(wù)

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

monthly任務(wù)備份后,會(huì)產(chǎn)生以monthly開頭的文件夾

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

《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份,服務(wù)器,運(yùn)維

小結(jié)

云服務(wù)商的硬盤還是蠻貴的,對(duì)于個(gè)人開發(fā)者而言,同時(shí)能省一些錢總是好的。

2023年的機(jī)械硬盤算是很便宜了,1千塊能買16TB的全新盤,搞一塊插到樹莓派,定期對(duì)服務(wù)器數(shù)據(jù)做增量備份,成本比云服務(wù)商的低很多。

如果你是一個(gè)上班族,辦公室和家里各部署一套rsnapshot備份,也算是支持?jǐn)?shù)據(jù)分布式異地容災(zāi)了。

為什么要把服務(wù)器數(shù)據(jù)備份到本地?目前的ICP備案搞的風(fēng)風(fēng)火火,買了服務(wù)器,由于備案的限制,也不能馬上使用80,443等端口,即使服務(wù)器備了案,解析的域名也會(huì)受到限制,如果有一天,由于某種不可抗力,把個(gè)人備案關(guān)聯(lián)的服務(wù)器的數(shù)據(jù)全部封存,也不是不可能,所以,做好本地?cái)?shù)據(jù)備份,總是沒錯(cuò)的,反正成本也不高。

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

本文永久更新地址(歡迎來讀留言,寫評(píng)論):

https://www.v2fy.com/p/2023-08-17-rsnapshot-1692258217000文章來源地址http://www.zghlxwxcb.cn/news/detail-657206.html

到了這里,關(guān)于《樹莓派4B家庭服務(wù)器搭建指南》第二十期:在樹莓派運(yùn)行rsnapshot, 實(shí)現(xiàn)對(duì)服務(wù)器數(shù)據(jù)低成本增量本地備份的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 樹莓派4B(Raspberry Pi 4B)使用docker搭建阿里巴巴sentinel服務(wù)

    樹莓派4B(Raspberry Pi 4B)使用docker搭建阿里巴巴sentinel服務(wù)

    由于國內(nèi)訪問不了docker hub,而國內(nèi)鏡像倉庫又沒有適配樹莓派ARM架構(gòu)的sentinel鏡像,所以我們只能退而求其次——自己動(dòng)手構(gòu)建鏡像。本文基于Ubuntu,Java8,sentinel-dashboard-1.8.7講解 下載sentinel-dashboard-1.8.7.jar 到GitHub(Releases · alibaba/Sentinel (github.com))下載 下載jdk-8u391-linux-aar

    2024年02月20日
    瀏覽(31)
  • 搭建家庭影音媒體中心 --公網(wǎng)遠(yuǎn)程連接Jellyfin流媒體服務(wù)器

    搭建家庭影音媒體中心 --公網(wǎng)遠(yuǎn)程連接Jellyfin流媒體服務(wù)器

    轉(zhuǎn)載自遠(yuǎn)程穿透的文章:【智能家居】Home Assistant入門安裝并內(nèi)網(wǎng)穿透實(shí)現(xiàn)遠(yuǎn)程安全控制 Home Assistant(以下簡稱HA)是個(gè)開源的智能家居平臺(tái),也叫家庭助手,就像一個(gè)軟件,比如我們的QQ軟件,微信軟件。 Home Assistant把家中的智能家居設(shè)備整合到HA中,它能夠接入的設(shè)備非常的

    2024年02月01日
    瀏覽(28)
  • 【樹莓派烤肉 001】從 0 開始用自己的樹莓派搭建服務(wù)器:運(yùn)維篇

    【樹莓派烤肉 001】從 0 開始用自己的樹莓派搭建服務(wù)器:運(yùn)維篇

    沒錯(cuò),我承認(rèn)這個(gè)標(biāo)題寫的很好吃…… 話說我家里那只樹莓派 4B 8GB 放了兩年了,除了吃灰還是吃灰~ 于是我想用它做一些非同尋常的事情,比如搭服務(wù)器。之前建網(wǎng)站都是用的 GitHub Pages,這次我們整個(gè)真實(shí)的 LAMP 環(huán)境。話不多說,下面開始搭建運(yùn)行環(huán)境~ (不用擔(dān)心樹莓派

    2024年02月09日
    瀏覽(23)
  • 如何利用家庭寬帶和自己家里的電腦,搭建可在公網(wǎng)訪問的服務(wù)器

    像軟件開發(fā)工程師,我們經(jīng)常需要在任何地方訪問家里的文件服務(wù)器,或者通過 http與https訪問自己家里的web服務(wù)器。但是,由于公網(wǎng)IP稀缺,家庭寬帶一般都沒有 IPv4的公網(wǎng)IP。而且,即使你有IPv4的公網(wǎng)IP,一般運(yùn)營商為家庭寬帶封禁了80,8080,443,23等端口。非常的不方便。 ?

    2024年02月05日
    瀏覽(87)
  • 樹莓派本地快速搭建web服務(wù)器,并發(fā)布公網(wǎng)訪問

    樹莓派本地快速搭建web服務(wù)器,并發(fā)布公網(wǎng)訪問

    隨著科技的發(fā)展,電子工業(yè)也在不斷進(jìn)步,我們身邊的電子設(shè)備也在朝著小型化和多功能化演進(jìn),以往體積龐大的電腦也在逐漸縮小體積。樹莓派作為一臺(tái)功能完備的硬件設(shè)備,其功耗和體積遠(yuǎn)小于傳統(tǒng)的臺(tái)式電腦,并且在大部分功能上并不遜于臺(tái)式機(jī),因此被開發(fā)出多種應(yīng)

    2024年02月15日
    瀏覽(37)
  • 家庭寬帶在有ipv6公網(wǎng)環(huán)境下,配置本地tomcat服務(wù)器+域名+ssl+ddns,實(shí)現(xiàn)ipv6建站、搭建簡易的文件服務(wù)器、搭建webdav服務(wù)器等功能

    家庭寬帶在有ipv6公網(wǎng)環(huán)境下,配置本地tomcat服務(wù)器+域名+ssl+ddns,實(shí)現(xiàn)ipv6建站、搭建簡易的文件服務(wù)器、搭建webdav服務(wù)器等功能

    必備條件: ????????寬帶運(yùn)營商提供了ipv6 ??????? 光貓撥號(hào)改為路由器撥號(hào)且路由器開啟了ipv6 ????????運(yùn)營商未屏蔽ipv6的80/443端口(如果屏蔽了常用端口,那么可以嘗試高一點(diǎn)的端口號(hào)。端口號(hào)范圍:1 - 65535) 目錄 一、阿里云申請(qǐng)域名ssl證書 1、申請(qǐng)域名 2、申

    2024年02月06日
    瀏覽(55)
  • 在樹莓派搭建私人音樂服務(wù)器navidrome,并支持顯示中文歌詞

    在樹莓派搭建私人音樂服務(wù)器navidrome,并支持顯示中文歌詞

    2023年,國產(chǎn)硬盤價(jià)格真的是經(jīng)濟(jì)實(shí)惠,而版權(quán)之爭導(dǎo)致我們無法從單個(gè)平臺(tái)獲取想聽的歌,本期我們將在樹莓派搭建一個(gè)navidrome私人音樂服務(wù)器,同時(shí)支持顯示歌詞。(雖然jellyfin也支持管理歌曲,但不支持顯示歌詞,我認(rèn)為顯示歌詞是剛需,最終選擇了navidrome) 本文是樹莓

    2024年02月06日
    瀏覽(29)
  • 【無公網(wǎng)IP內(nèi)網(wǎng)穿透】 搭建Emby媒體庫服務(wù)器并遠(yuǎn)程訪問「家庭私人影院」

    【無公網(wǎng)IP內(nèi)網(wǎng)穿透】 搭建Emby媒體庫服務(wù)器并遠(yuǎn)程訪問「家庭私人影院」

    目錄 1.前言 2. Emby網(wǎng)站搭建 2.1. Emby下載和安裝 2.2 Emby網(wǎng)頁測試 3. 本地網(wǎng)頁發(fā)布 3.1 注冊并安裝cpolar內(nèi)網(wǎng)穿透 3.2 Cpolar云端設(shè)置 3.3 Cpolar內(nèi)網(wǎng)穿透本地設(shè)置 4.公網(wǎng)訪問測試 5.結(jié)語 在現(xiàn)代五花八門的網(wǎng)絡(luò)應(yīng)用場景中,觀看視頻絕對(duì)是主力應(yīng)用場景之一,加上移動(dòng)網(wǎng)絡(luò)技術(shù)的發(fā)展,

    2024年02月07日
    瀏覽(24)
  • 二:原神本地服務(wù)器(sifu)搭建環(huán)境配置教程第二篇

    二:原神本地服務(wù)器(sifu)搭建環(huán)境配置教程第二篇

    安裝jdk 雙擊msi安裝文件,一路到底就歐克,傻瓜式安裝。 ?安裝數(shù)據(jù)庫 也是一路yes,后面在安裝界面會(huì)有一個(gè)詢問你是否安裝最新版,可選可不選,不選安裝會(huì)快些 中間提示服務(wù)啟動(dòng)不成功也無所謂,可以忽略。后面會(huì)教你怎么開 ?安裝代理器 ?雙擊開始安裝一路yes就行

    2024年02月13日
    瀏覽(31)
  • 使用Python搭建代理服務(wù)器- 爬蟲代理服務(wù)器詳細(xì)指南

    使用Python搭建代理服務(wù)器- 爬蟲代理服務(wù)器詳細(xì)指南

    搭建一個(gè)Python爬蟲代理服務(wù)器可以讓你更方便地管理和使用代理IP。下面是一個(gè)詳細(xì)的教程來幫助你搭建一個(gè)簡單的Python爬蟲代理服務(wù)器: 1. 首先,確保你已經(jīng)安裝了Python。你可以在官方網(wǎng)站(https://www.python.org/)下載并安裝最新版本的Python。 2. 安裝所需的Python庫。打開終端或

    2024年02月15日
    瀏覽(27)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包