「インストール - TimeShift」の版間の差分

提供:MochiuWiki : SUSE, EC, PCB
ナビゲーションに移動 検索に移動
(ページの作成:「== 概要 == Timeshiftは、システムレベルのバックアップに最適なオープンソースのバックアップおよび復元ソフトウェアである。<br> Windowsのシステムの復元やMacOSのTime Machineのような機能を提供する。<br> <br> Rsyncコマンドとハードリンクを使用して、増分アプローチでスナップショットを取得する。<br> Timeshiftを使用することにより、例えば、何かをイン…」)
 
39行目: 39行目:
# 展開したファイルを、任意のディレクトリに配置する。
# 展開したファイルを、任意のディレクトリに配置する。
#: <code>cp -r timeshift-* <TimeShiftのインストールディレクトリ></code>
#: <code>cp -r timeshift-* <TimeShiftのインストールディレクトリ></code>
<br>
==== ソースコードからインストール ====
# ビルドに必要なライブラリをインストールする。
#: <code>sudo zypper install vala libvala-0_54-0 libvala-0_54-devel libgee-devel vte-devel json-glib-devel</code>
# [https://github.com/teejee2008/timeshift TimeShiftのGithub]にアクセスして、ソースコードをダウンロードする。
# ダウンロードしたファイルを解凍する。
#: <code>tar xf timeshift-<バージョン>.tar.gz</code>
#: <code>cd timeshift-<バージョン></code>
# TimeShiftをビルドおよびインストールする。
#: <code>make app-console app-gtk -j $(nproc)</code>
#: <code>make prefix=<TimeShiftのインストールディレクトリ> sysconfdir=<TimeShiftのインストールディレクトリ> install</code>
<br>
PolKitアクションファイルを作成する。<br>
sudo vi /usr/share/polkit-1/actions/in.teejeetech.pkexec.timeshift.policy
<br>
<syntaxhighlight lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
  <vendor>Tony George</vendor>
  <vendor_url>https://github.com/teejee2008</vendor_url>
  <action id="in.teejeetech.pkexec.timeshift-gtk">
    <message gettext-domain="timeshift">Authentication is required to run Timeshift as Administrator</message>
    <description>Run Timeshift as Administrator</description>
    <icon_name>timeshift</icon_name>
    <defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>auth_admin</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/<TimeShiftのインストールディレクトリ>/bin/timeshift-gtk</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
  </action>
  <action id="in.teejeetech.pkexec.timeshift">
    <message gettext-domain="timeshift">Authentication is required to run Timeshift as Administrator</message>
    <description>Run Timeshift as Administrator</description>
    <icon_name>timeshift</icon_name>
    <defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>auth_admin</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/<TimeShiftのインストールディレクトリ>/bin/timeshift</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
  </action>
</policyconfig>
</syntaxhighlight>
<br>
TimeShiftのデスクトップエントリファイルを作成する。<br>
vi ~/.local/share/applications/timeshift-gtk.desktop
<br>
# ~/.local/share/applications/timeshift-gtk.desktopファイル
[Desktop Entry]
Type=Application
Name=Timeshift
GenericName=System Restore Utility
GenericName[ja]=システムの復元ユーティリティ
Comment=System Restore Utility
Comment[ja]=システムの復元ユーティリティ
Exec=/<TimeShiftのインストールディレクトリ>/bin/timeshift-launcher
Icon=/<TimeShiftのインストールディレクトリ>/share/icons/hicolor/128x128/apps/timeshift.png
Categories=System;
MimeType=
Terminal=false
X-KDE-StartupNotify=false
X-GNOME-UsesNotifications=true
<br>
<br>
==== TimeShiftの日本語化 ====
==== TimeShiftの日本語化 ====

2023年3月28日 (火) 21:56時点における版

概要

Timeshiftは、システムレベルのバックアップに最適なオープンソースのバックアップおよび復元ソフトウェアである。
Windowsのシステムの復元やMacOSのTime Machineのような機能を提供する。

Rsyncコマンドとハードリンクを使用して、増分アプローチでスナップショットを取得する。
Timeshiftを使用することにより、例えば、何かをインストールしてシステムが破損した場合やアップデートに失敗した場合に、迅速かつ安全に以前の状態にロールバックできる。

ただし、システムファイルや設定のみをバックアップするように設計されているため、ホームディレクトリに存在するデータをバックアップする場合は、
別途、Deja Dup、Rsnapshot、Restic、Rsyncを使用する。

初期設定では、ドキュメント、ピクチャ、ミュージック等のホームディレクトリにあるファイルはバックアップから除外される。
そのため、システムを以前の状態に復元する際に、ユーザデータは変更されないことに注意する。

Timeshiftの主な機能は、以下の通りである。

  • CLIおよびGUIでの動作
  • BTRFSファイルシステムのサポート
  • 複数のバックアップレベル(例. 毎時、毎日、毎週、毎月、ブート時)
  • Cronによるスケジュールバックアップ
  • オンラインおよびオフラインでの復元
  • クロスディストリビューション・リストアのサポート


また、TimeshiftのソースコードはGitHubで入手できる。
https://github.com/teejee2008/timeshift


TimeShiftのインストール

SLEおよびopenSUSEの公式リポジトリにはTimeShiftが存在しないため、有志が作成しているリポジトリを利用する必要がある。
または、リポジトリを利用せずに、RPMファイルを展開して任意のディレクトリに配置することでもTimeShiftが使用できる。

リポジトリを追加してインストール

  1. SUSEのソフトウェアセンターにアクセスして、SLE向けを選択して、x86_64のRPMファイルをダウンロードする。
  2. ダウンロードしたRPMファイルをインストールする。
    sudo zypper install ./timeshift-*.rpm


RPMファイルを展開して任意のディレクトリにインストール

  1. SUSEのソフトウェアセンターにアクセスして、SLE向けを選択して、x86_64のRPMファイルをダウンロードする。
  2. ダウンロードしたRPMファイルを展開する。
    rpm2cpio timeshift-*.rpm | cpio -id
  3. 展開したファイルを、任意のディレクトリに配置する。
    cp -r timeshift-* <TimeShiftのインストールディレクトリ>


ソースコードからインストール

  1. ビルドに必要なライブラリをインストールする。
    sudo zypper install vala libvala-0_54-0 libvala-0_54-devel libgee-devel vte-devel json-glib-devel
  2. TimeShiftのGithubにアクセスして、ソースコードをダウンロードする。
  3. ダウンロードしたファイルを解凍する。
    tar xf timeshift-<バージョン>.tar.gz
    cd timeshift-<バージョン>
  4. TimeShiftをビルドおよびインストールする。
    make app-console app-gtk -j $(nproc)
    make prefix=<TimeShiftのインストールディレクトリ> sysconfdir=<TimeShiftのインストールディレクトリ> install


PolKitアクションファイルを作成する。

sudo vi /usr/share/polkit-1/actions/in.teejeetech.pkexec.timeshift.policy


 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
 <policyconfig>
   <vendor>Tony George</vendor>
   <vendor_url>https://github.com/teejee2008</vendor_url>
   <action id="in.teejeetech.pkexec.timeshift-gtk">
     <message gettext-domain="timeshift">Authentication is required to run Timeshift as Administrator</message>
     <description>Run Timeshift as Administrator</description>
     <icon_name>timeshift</icon_name>
     <defaults>
       <allow_any>auth_admin</allow_any>
       <allow_inactive>auth_admin</allow_inactive>
       <allow_active>auth_admin</allow_active>
     </defaults>
     <annotate key="org.freedesktop.policykit.exec.path">/<TimeShiftのインストールディレクトリ>/bin/timeshift-gtk</annotate>
     <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
   </action>
   <action id="in.teejeetech.pkexec.timeshift">
     <message gettext-domain="timeshift">Authentication is required to run Timeshift as Administrator</message>
     <description>Run Timeshift as Administrator</description>
     <icon_name>timeshift</icon_name>
     <defaults>
       <allow_any>auth_admin</allow_any>
       <allow_inactive>auth_admin</allow_inactive>
       <allow_active>auth_admin</allow_active>
     </defaults>
     <annotate key="org.freedesktop.policykit.exec.path">/<TimeShiftのインストールディレクトリ>/bin/timeshift</annotate>
     <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
   </action>
 </policyconfig>


TimeShiftのデスクトップエントリファイルを作成する。

vi ~/.local/share/applications/timeshift-gtk.desktop


# ~/.local/share/applications/timeshift-gtk.desktopファイル

[Desktop Entry]
Type=Application
Name=Timeshift
GenericName=System Restore Utility
GenericName[ja]=システムの復元ユーティリティ
Comment=System Restore Utility
Comment[ja]=システムの復元ユーティリティ
Exec=/<TimeShiftのインストールディレクトリ>/bin/timeshift-launcher
Icon=/<TimeShiftのインストールディレクトリ>/share/icons/hicolor/128x128/apps/timeshift.png
Categories=System;
MimeType=
Terminal=false
X-KDE-StartupNotify=false
X-GNOME-UsesNotifications=true


TimeShiftの日本語化

  1. SUSEのソフトウェアセンターにアクセスして、Leap向けを選択して、x86_64のRPMファイルをダウンロードする。
    TimeShiftのバージョンが異なる場合でも、ほとんどが日本語化される。
  2. ダウンロードしたRPMファイルを展開する。
    rpm2cpio timeshift-*.rpm | cpio -id
  3. 展開したファイルにあるusr/share/locale/ja/LC_MESSAGES/timeshift.moファイルを、/usr/share/locale/ja/LC_MESSAGESディレクトリにコピーする。
    cd timeshift-*/usr/share/locale/ja/LC_MESSAGES
    sudo cp -r timeshift.mo /usr/share/locale/ja/LC_MESSAGES
  4. TimeShiftを起動して、日本語化されているかどうかを確認する。



TimeShiftの使用方法

バックアップ方式は以下の2通りから選択できる。

  • BtrFS (B-Tree File System)
  • Rsync


Rsync

rsyncコマンドにより、バックアップ先にファイルをコピーする方式である。 事前にコピー先のファイル名やタイムスタンプ等を確認して、更新があるファイルのみコピーするため、2度目以降のバックアップが特に高速である。

バックアップの世代管理には、--link-destオプションを使用している。 --link-destオプションを付加することにより、以下のような動作となる。

  • 前回のバックアップから更新の無いファイルは、前回のバックアップファイルからのハードリンクを生成する。
  • 前回のバックアップから更新のあるファイルは、バックアップ元からコピーを生成する。


ハードリンクは、ファイルの実体(inode)を共有した複数のファイルを作成するという特性を持つ。 そのため、ハードリンクによる差分バックアップは、以下の強力なメリットがある。

  • ハードリンクの作成はディスク容量をほとんど消費しない。
  • ハードリンクの作成は非常に高速である。
  • 世代間に依存関係がないため、各世代は順不同で高速に削除できる。
  • ハードリンクは基本機能であるため、不具合が発生する懸念は少ない。


rsyncコマンドはハードリンクの仕組みを利用していることから、ファイルシステム自体がハードリンクに対応している必要がある。
ほとんどの場合は問題無いが、sshfsはハードリンクに対応していないため注意すること。

BtrFS

BtrFSのスナップショット機能を使ってバックアップを取得する方式である。

BtrFSを使用するには、以下の条件が必須となる。

  • バックアップ元がBtrFSを使用していることが前提である。
  • その他、SubVolume構成にも条件がある。



TimeShiftの設定

Timeshiftは設定内容に応じて、/etc/cron.dディレクトリ下のファイルを編集するため、スーパユーザ権限が必要である。
したがって、GUIからの起動時には、sudoコマンドと同様にパスワードを求められる。

この制御は、Polkit(/usr/share/polkit-1/actions/in.teejeetech.pkexec.timeshift.policy)で実装されている。
Polkitとは、特権が必要な操作を非特権プロセスから実行するための仕組みであり、sudoコマンドと似たような役割を持つ。

TimeShiftのメイン画面から、[設定]メニューバーまたは[ウィザード]メニューバーを選択する。
なお、Timeshiftの設定が反映されるタイミングは、Timeshiftを終了した時となることに注意すること。