3
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Raspberry pi のバックアップ

Last updated at Posted at 2019-05-28

Raspberry pi のバックアップ

せっかくインストールしたRaspberry Piを手軽にバックアップする方法をまとめてみました。

バックアップ先は、Windows10を想定した手順として記載します。

Windows 10 フォルダ共有設定

適当な場所にフォルダを作成します。
例として、share という名前のフォルダを作成します。

フォルダを右クリック > プロパティ >共有タブを選択し、詳細な共有をクリックします。
008.jpg
このフォルダーを共有する にチェックを入れて「OK」をクリックします。
006.jpg
共有フォルダにeveryoneを追加し、読み取り/書き込み権限を付与します。
003.jpg

※パスワードなしで共有させたい場合は、以下の設定を実施します。
ネットワークと共有センター > 共有の詳細設定の変更をクリックします。
001.jpg
すべてのネットワーク > パスワードの保護共有 でパスワード保護共有を無効にする にチェックを入れて変更の保存をクリックします。
002.jpg

Windows 共有フォルダをRaspberry Piからマウント

Windows 共有フォルダをRaspberry Piからマウントします。
Windows のIPアドレスが、192.18.11.** 、共有フォルダ名が、shareの場合。

pi@raspberrypi:~ $ sudo mount -t cifs //192.168.11.**/share /mnt/nas -o iocharset=utf8
Password for root@//192.168.11.**/share:  
pi@raspberrypi:~ $ mount |grep nas
//192.168.11.**/share on /mnt/nas type cifs (rw,relatime,vers=default,cache=strict,username=root,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.11.**,file_mode=0755,dir_mode=0755,soft,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1)

バックアップ

ddコマンドでSDカードのデータをWindows共有先にコピーします。
32GBのSDを使用していましたので、コピーしたファイルも32GBになります。
バックアップ先の空き容量にご注意ください。

sudo dd if=/dev/mmcblk0 of=/mnt/share/`date "+%Y%m%d-%H%M"`.img bs=16M status=progress 

なおバックアップ時間は、30分程度かかりました。

リストア

バックアップしたイメージファイルをbalenaEtcherを使ってSDカードにFlashします。

balenaEtcherは、以下のサイトよりダウンロードできます。

balenaEtcher
https://www.balena.io/etcher/

バックアップしたイメージを選択して、Flash!すれば完了します。

007.jpg
3
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?