rsnapshot をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
本家様 [[http://www.rsnapshot.org/>+http://www.rsnapshot....
#code(nonumber){{
rsnapshot is a filesystem snapshot utility based on rsync...
The code makes extensive use of hard links whenever possi...
(DeepL様翻訳)
rsnapshot は rsync ベースのファイルシステムスナップショッ...
このコードでは、可能な限りハードリンクを多用し、必要なデ...
}}
昨日の(特定フォルダの)スナップショット、一昨日のスナップ...
macOSで言う所の「timemachine」かな。それをローカルのマシ...
***インストール [#kcf14054]
#code(nonumber){{
[root@rockylinux9 ~]# dnf install epel-release -y
[root@rockylinux9 ~]# dnf install rsnapshot -y
[root@rockylinux9 ~]# rpm -qai rsnapshot
Name : rsnapshot
Version : 1.5.1
Release : 1.el9
Architecture: noarch
Install Date: Fri 11 Jul 2025 08:21:18 PM JST
Group : Unspecified
Size : 396168
License : GPL-2.0-or-later
Signature : RSA/SHA256, Sun 09 Feb 2025 10:59:27 AM JST...
Source RPM : rsnapshot-1.5.1-1.el9.src.rpm
Build Date : Sun 09 Feb 2025 10:55:09 AM JST
Build Host : buildvm-a64-23.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://rsnapshot.org/
Bug URL : https://bugz.fedoraproject.org/rsnapshot
Summary : Local and remote filesystem snapshot utility
Description :
This is a remote backup program that uses rsync to take b...
filesystems. It uses hard links to save space on disk.
[root@rockylinux9 ~]#
}}
***rsnapshot設定 [#g0b49006]
まずはローカルフォルダのバックアップを定義してみます。
バックアップ対象は &color(magenta){/home/}; と 「&color(m...
設定ファイル
&color(red){*};スペースはタブ(\t)です
#code(nonumber){{
[root@rockylinux9 ~]# mv /etc/rsnapshot.conf /etc/rsnapsh...
[root@rockylinux9 ~]# grep -v -e '^\s*#' -e '^\s*$' /etc/...
[root@rockylinux9 ~]# cat /etc/rsnapshot.conf
config_version 1.2
snapshot_root /.snapshots/
cmd_rm /usr/bin/rm
cmd_rsync /usr/bin/rsync
cmd_logger /usr/bin/logger
retain alpha 6
retain beta 7
retain gamma 4
verbose 2
loglevel 3
lockfile /var/run/rsnapshot.pid
backup /home/ localhost/
backup /etc/ localhost/
backup /usr/local/ localhost/
[root@rockylinux9 ~]#
}}
これに修正を加えて
#code(nonumber){{
[root@rockylinux9 ~]# cat /etc/rsnapshot.conf
config_version 1.2
lockfile /var/run/rsnapshot.pid
cmd_rsync /usr/bin/rsync
snapshot_root /bk/ #バックアップファイルは/o...
retain alpha 6 # 6回スナップショットを撮...
retain beta 7 # 7回スナップショットを撮...
retain gamma 4 # 4回スナップショットを撮...
backup /home/ localhost/
backup /var/log/ localhost/
[root@rockylinux9 ~]#
}}
最後の「backup」行の「localhost」はバックアップ対象のマシ...
&color(red){*};以前は「retain」の代わりに「interval」が使...
rsnapshotの設定は上記でいいが、次は実際にrsnapshotを実際...
上記の設定どおりに動かすには下記のようにします
#code(nonumber){{
[root@c ~]# crontab -e
MAILTO=""
# 平日月曜日から金曜日の8,10,12,14,16,18の0時に alpha 項...
00 8,10,12,14,16,18 * * 1-5 /usr/bin/rsnapshot alp...
# 火曜日から土曜日の午前1時00分に beta を実行します
00 1 * * 2-6 /usr/bin/rsnapshot beta
# 月曜日の午前2時00分に gamma を実行します
00 2 * * 1 /usr/bin/rsnapshot gamma
}}
crontabの書式は「man 5 crontab」で確認できます
***複数の場所をそれぞれ専用の場所で保存したい [#l832a733]
現状はバックアップ元は1つのバックアップ先、「snapshot_ro...
#code(nonumber){{
/home/ --+
/opt/data/ --+------------> 「/backup」(snapshot_root)
/etc/ --+
/data/ +--------------> 「/data-backup」
}}
rsnapshotのhelpを見ると、[-c]で設定ファイルが指定できるみ...
#code(nonumber){{
[root@centos7 ~]# rsnapshot help
rsnapshot
Usage: rsnapshot [-vtxqVD] [-c cfgfile] [command] [args]
Type "man rsnapshot" for more information.
rsnapshot is a filesystem snapshot utility. It can take i...
snapshots of local and remote filesystems for any number ...
rsnapshot comes with ABSOLUTELY NO WARRANTY. This is fre...
and you are welcome to redistribute it under certain cond...
See the GNU General Public License for details.
Options:
-v verbose - Show equivalent shell commands bei...
-t test - Show verbose output, but don't tou...
This will be similar, but not alwa...
as the real output from a live run.
-c [file] - Specify alternate config file (-c ...
-q quiet - Suppress non-fatal warnings.
-V extra verbose - The same as -v, but with more deta...
-D debug - A firehose of diagnostic informati...
-x one_fs - Don't cross filesystems (same as -...
Commands:
[backuplevel] - A backup level as defined in rsnap...
configtest - Syntax check the config file.
sync [dest] - Sync files, without rotating. "syn...
enabled for this to work. If a ful...
destination is given as an optiona...
those files will be synced.
diff - Front-end interface to the rsnapsh...
Accepts two optional arguments whi...
filesystem paths or backup directo...
snapshot_root (e.g., /etc/ beta.0/...
is to compare the two most recent ...
du - Show disk usage in the snapshot_ro...
Accepts an optional destination pa...
across snapshots (e.g., localhost/...
version - Show the version number for rsnaps...
help - Show this help message.
[root@centos7 ~]#
}}
なので「/data」向けのrsnapshot設定ファイルを作ってそれを...
#code(nonumber){{
[root@centos7 ~]# cp /etc/rsnapshot.conf /etc/rsnapshot.d...
[root@centos7 ~]# vi /etc/rsnapshot.data.conf
:
snapshot_root /data-backup/
logfile /var/log/rsnapshot.data
lockfile /var/run/rsnapshot.data.pid
backup /data/ localhost/
:
[root@centos7 ~]#
}}
&color(red){*}; 「logfile」と「lockfile」の名称は既存のと...
っでcronは下記のようにする
#code(nonumber){{
00 * * * * /usr/bin/rsnapshot hourly
10 23 * * * /usr/bin/rsnapshot daily
20 23 * * 4 /usr/bin/rsnapshot weekly
00 * * * * /usr/bin/rsnapshot -c /etc/rsnapshot.da...
10 23 * * * /usr/bin/rsnapshot -c /etc/rsnapshot.d...
20 23 * * 4 /usr/bin/rsnapshot -c /etc/rsnapshot.d...
}}
***リモートからファイルバックアップ [#m99d9009]
rsyncでバックアップしているので、複数台のリモートサーバの...
&ref(2013y10m10d_220201855.png,nolink,noborder);
こんな感じで
まず、rsnapshotを実行するノードで 公開鍵 を作ります
#code(nonumber){{
[root@rockylinux9 ~]# ssh-keygen -t ed25519 -f rsnapshot
:
(パスフレーズなしで作成)
:
[root@rockylinux9 ~]# ls -l rsnapshot*
-rw-------. 1 root root 411 Jul 12 09:07 rsnapshot
-rw-r--r--. 1 root root 98 Jul 12 09:07 rsnapshot.pub
[root@rockylinux9 ~]# cat rsnapshot.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICBWqtZysqXp1Iag+/Vrk...
[root@rockylinux9 ~]#
}}
この公開鍵(rsnapshot.pub)の中身を バックアップ対象ノード ...
#code(nonumber){{
root@ubuntu24:~# echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AA...
}}
っでパスワードなしでバックアップ対象ノードに入れるかのテ...
#code(nonumber){{
[root@rockylinux9 ~]# ssh -i rsnapshot -l root ubuntu24
root@ubuntu24:~#
}}
っと入れたら事前準備は完了
っで、バックアップ対象の場所は「/home」なら
#code(nonumber){{
[root@rockylinux9 ~]# cat /etc/rsnapshot.conf
config_version 1.2
lockfile /var/run/rsnapshot.pid
cmd_rsync /usr/bin/rsync
snapshot_root /bk/ #バックアップファイルは/o...
retain alpha 6 # 6回スナップショットを撮...
retain beta 7 # 7回スナップショットを撮...
retain gamma 4 # 4回スナップショットを撮...
backup /home/ localhost/
backup /var/log/ localhost/
cmd_ssh /usr/bin/ssh
ssh_args -p 22 -i /root/rsnapshot #...
backup root@ubuntu24:/home/ ubuntu24/
[root@rockylinux9 ~]#
}}
&color(red){*};スペースは全てtab(\t)であることに注意
***めも [#h55dad4d]
作ったファイルの設定を確認に
#code(nonumber){{
rsnapshot configtest
}}
で文法チェックを多なう事
ログは
#code(nonumber){{
verbose 2
loglevel 3
logfile /var/log/rsnapshot
}}
で定義できる。verbose, loglevelの数字は「1」がQuiet, 「...
っがlogrotateのエントリーがないので、「/varlog/rsnapshot...
っでlogrotateのエントリーを入れる
#code(nonumber){{
[root@rockylinux9 ~]# vi /etc/logrotate.d/rsnapshot
/var/log/rsnapshot {
monthly
missingok
notifempty
rotate 12
compress
delaycompress
}
[root@rockylinux9 ~]#
}}
上記は毎月のログローテーションで、12回分残す。ローテイシ...
終了行:
本家様 [[http://www.rsnapshot.org/>+http://www.rsnapshot....
#code(nonumber){{
rsnapshot is a filesystem snapshot utility based on rsync...
The code makes extensive use of hard links whenever possi...
(DeepL様翻訳)
rsnapshot は rsync ベースのファイルシステムスナップショッ...
このコードでは、可能な限りハードリンクを多用し、必要なデ...
}}
昨日の(特定フォルダの)スナップショット、一昨日のスナップ...
macOSで言う所の「timemachine」かな。それをローカルのマシ...
***インストール [#kcf14054]
#code(nonumber){{
[root@rockylinux9 ~]# dnf install epel-release -y
[root@rockylinux9 ~]# dnf install rsnapshot -y
[root@rockylinux9 ~]# rpm -qai rsnapshot
Name : rsnapshot
Version : 1.5.1
Release : 1.el9
Architecture: noarch
Install Date: Fri 11 Jul 2025 08:21:18 PM JST
Group : Unspecified
Size : 396168
License : GPL-2.0-or-later
Signature : RSA/SHA256, Sun 09 Feb 2025 10:59:27 AM JST...
Source RPM : rsnapshot-1.5.1-1.el9.src.rpm
Build Date : Sun 09 Feb 2025 10:55:09 AM JST
Build Host : buildvm-a64-23.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://rsnapshot.org/
Bug URL : https://bugz.fedoraproject.org/rsnapshot
Summary : Local and remote filesystem snapshot utility
Description :
This is a remote backup program that uses rsync to take b...
filesystems. It uses hard links to save space on disk.
[root@rockylinux9 ~]#
}}
***rsnapshot設定 [#g0b49006]
まずはローカルフォルダのバックアップを定義してみます。
バックアップ対象は &color(magenta){/home/}; と 「&color(m...
設定ファイル
&color(red){*};スペースはタブ(\t)です
#code(nonumber){{
[root@rockylinux9 ~]# mv /etc/rsnapshot.conf /etc/rsnapsh...
[root@rockylinux9 ~]# grep -v -e '^\s*#' -e '^\s*$' /etc/...
[root@rockylinux9 ~]# cat /etc/rsnapshot.conf
config_version 1.2
snapshot_root /.snapshots/
cmd_rm /usr/bin/rm
cmd_rsync /usr/bin/rsync
cmd_logger /usr/bin/logger
retain alpha 6
retain beta 7
retain gamma 4
verbose 2
loglevel 3
lockfile /var/run/rsnapshot.pid
backup /home/ localhost/
backup /etc/ localhost/
backup /usr/local/ localhost/
[root@rockylinux9 ~]#
}}
これに修正を加えて
#code(nonumber){{
[root@rockylinux9 ~]# cat /etc/rsnapshot.conf
config_version 1.2
lockfile /var/run/rsnapshot.pid
cmd_rsync /usr/bin/rsync
snapshot_root /bk/ #バックアップファイルは/o...
retain alpha 6 # 6回スナップショットを撮...
retain beta 7 # 7回スナップショットを撮...
retain gamma 4 # 4回スナップショットを撮...
backup /home/ localhost/
backup /var/log/ localhost/
[root@rockylinux9 ~]#
}}
最後の「backup」行の「localhost」はバックアップ対象のマシ...
&color(red){*};以前は「retain」の代わりに「interval」が使...
rsnapshotの設定は上記でいいが、次は実際にrsnapshotを実際...
上記の設定どおりに動かすには下記のようにします
#code(nonumber){{
[root@c ~]# crontab -e
MAILTO=""
# 平日月曜日から金曜日の8,10,12,14,16,18の0時に alpha 項...
00 8,10,12,14,16,18 * * 1-5 /usr/bin/rsnapshot alp...
# 火曜日から土曜日の午前1時00分に beta を実行します
00 1 * * 2-6 /usr/bin/rsnapshot beta
# 月曜日の午前2時00分に gamma を実行します
00 2 * * 1 /usr/bin/rsnapshot gamma
}}
crontabの書式は「man 5 crontab」で確認できます
***複数の場所をそれぞれ専用の場所で保存したい [#l832a733]
現状はバックアップ元は1つのバックアップ先、「snapshot_ro...
#code(nonumber){{
/home/ --+
/opt/data/ --+------------> 「/backup」(snapshot_root)
/etc/ --+
/data/ +--------------> 「/data-backup」
}}
rsnapshotのhelpを見ると、[-c]で設定ファイルが指定できるみ...
#code(nonumber){{
[root@centos7 ~]# rsnapshot help
rsnapshot
Usage: rsnapshot [-vtxqVD] [-c cfgfile] [command] [args]
Type "man rsnapshot" for more information.
rsnapshot is a filesystem snapshot utility. It can take i...
snapshots of local and remote filesystems for any number ...
rsnapshot comes with ABSOLUTELY NO WARRANTY. This is fre...
and you are welcome to redistribute it under certain cond...
See the GNU General Public License for details.
Options:
-v verbose - Show equivalent shell commands bei...
-t test - Show verbose output, but don't tou...
This will be similar, but not alwa...
as the real output from a live run.
-c [file] - Specify alternate config file (-c ...
-q quiet - Suppress non-fatal warnings.
-V extra verbose - The same as -v, but with more deta...
-D debug - A firehose of diagnostic informati...
-x one_fs - Don't cross filesystems (same as -...
Commands:
[backuplevel] - A backup level as defined in rsnap...
configtest - Syntax check the config file.
sync [dest] - Sync files, without rotating. "syn...
enabled for this to work. If a ful...
destination is given as an optiona...
those files will be synced.
diff - Front-end interface to the rsnapsh...
Accepts two optional arguments whi...
filesystem paths or backup directo...
snapshot_root (e.g., /etc/ beta.0/...
is to compare the two most recent ...
du - Show disk usage in the snapshot_ro...
Accepts an optional destination pa...
across snapshots (e.g., localhost/...
version - Show the version number for rsnaps...
help - Show this help message.
[root@centos7 ~]#
}}
なので「/data」向けのrsnapshot設定ファイルを作ってそれを...
#code(nonumber){{
[root@centos7 ~]# cp /etc/rsnapshot.conf /etc/rsnapshot.d...
[root@centos7 ~]# vi /etc/rsnapshot.data.conf
:
snapshot_root /data-backup/
logfile /var/log/rsnapshot.data
lockfile /var/run/rsnapshot.data.pid
backup /data/ localhost/
:
[root@centos7 ~]#
}}
&color(red){*}; 「logfile」と「lockfile」の名称は既存のと...
っでcronは下記のようにする
#code(nonumber){{
00 * * * * /usr/bin/rsnapshot hourly
10 23 * * * /usr/bin/rsnapshot daily
20 23 * * 4 /usr/bin/rsnapshot weekly
00 * * * * /usr/bin/rsnapshot -c /etc/rsnapshot.da...
10 23 * * * /usr/bin/rsnapshot -c /etc/rsnapshot.d...
20 23 * * 4 /usr/bin/rsnapshot -c /etc/rsnapshot.d...
}}
***リモートからファイルバックアップ [#m99d9009]
rsyncでバックアップしているので、複数台のリモートサーバの...
&ref(2013y10m10d_220201855.png,nolink,noborder);
こんな感じで
まず、rsnapshotを実行するノードで 公開鍵 を作ります
#code(nonumber){{
[root@rockylinux9 ~]# ssh-keygen -t ed25519 -f rsnapshot
:
(パスフレーズなしで作成)
:
[root@rockylinux9 ~]# ls -l rsnapshot*
-rw-------. 1 root root 411 Jul 12 09:07 rsnapshot
-rw-r--r--. 1 root root 98 Jul 12 09:07 rsnapshot.pub
[root@rockylinux9 ~]# cat rsnapshot.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICBWqtZysqXp1Iag+/Vrk...
[root@rockylinux9 ~]#
}}
この公開鍵(rsnapshot.pub)の中身を バックアップ対象ノード ...
#code(nonumber){{
root@ubuntu24:~# echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AA...
}}
っでパスワードなしでバックアップ対象ノードに入れるかのテ...
#code(nonumber){{
[root@rockylinux9 ~]# ssh -i rsnapshot -l root ubuntu24
root@ubuntu24:~#
}}
っと入れたら事前準備は完了
っで、バックアップ対象の場所は「/home」なら
#code(nonumber){{
[root@rockylinux9 ~]# cat /etc/rsnapshot.conf
config_version 1.2
lockfile /var/run/rsnapshot.pid
cmd_rsync /usr/bin/rsync
snapshot_root /bk/ #バックアップファイルは/o...
retain alpha 6 # 6回スナップショットを撮...
retain beta 7 # 7回スナップショットを撮...
retain gamma 4 # 4回スナップショットを撮...
backup /home/ localhost/
backup /var/log/ localhost/
cmd_ssh /usr/bin/ssh
ssh_args -p 22 -i /root/rsnapshot #...
backup root@ubuntu24:/home/ ubuntu24/
[root@rockylinux9 ~]#
}}
&color(red){*};スペースは全てtab(\t)であることに注意
***めも [#h55dad4d]
作ったファイルの設定を確認に
#code(nonumber){{
rsnapshot configtest
}}
で文法チェックを多なう事
ログは
#code(nonumber){{
verbose 2
loglevel 3
logfile /var/log/rsnapshot
}}
で定義できる。verbose, loglevelの数字は「1」がQuiet, 「...
っがlogrotateのエントリーがないので、「/varlog/rsnapshot...
っでlogrotateのエントリーを入れる
#code(nonumber){{
[root@rockylinux9 ~]# vi /etc/logrotate.d/rsnapshot
/var/log/rsnapshot {
monthly
missingok
notifempty
rotate 12
compress
delaycompress
}
[root@rockylinux9 ~]#
}}
上記は毎月のログローテーションで、12回分残す。ローテイシ...
ページ名:
1