0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Linux マウント & Samba設定 & Windows11からバックアップ迄を整理

Last updated at Posted at 2025-08-01

設定誤りがあって lubuntu導入からバックアップできていなかったので Linux マウント & Samba設定 & Windows11からバックアップ迄を整理

1.Diskの状態を確認

sudo fdisk -l

/dev/sdb1 1tb /dev/sdb2 1tb と見える。

2.UUIDを表示&コピー

sudo blkid /dev/sdb1
sudo blkid /dev/sdb1

3.マウント先を作成

mkdir media
mkdir media/disk1
mkdir media/disk2
sudo chmod 777  media/disk1
sudo chmod 777  media/disk2

4.マウント

sudo vim /etc/fstab

中身は以下を追加 コピーしたUUID を貼り付け。

UUID=xxxxxxxxxxxxxx /media/disk1 ext4 defaults 0 0
UUID=xxxxxxxxxxxxxx /media/disk2 ext4 defaults 0 0

5.リプートで マウントされたことがわかる。当方のマシンでは ディスクトップに表示される。

df -h

6.samba導入

sudo apt-get install samba -y

Samba パスワード設定

sudo smbpasswd -a miyamo
sudo smbpasswd -e miyamo

ifconfigで確認

ifconfig

Samba 設定

sudo vim /etc/samba/smb.conf

中身を以下で変更

   interface 192.168.1.0/24 enp4s0

[lubuntu_disk1]
   path = /media/disk1
   available = yes
   read only = no
   browsable = yes
   public = yes
   writable = yes
   quest ok = no
[lubuntu_disk2]
   path = /media/disk2
   available = yes
   read only = no
   browsable = yes
   public = yes
   writable = yes
   quest ok = no  

以下を実行

sudo systemctl enable smbd.service
sudo systemctl reload smbd.service
sudo systemctl restart smbd.service

FW設定
 あとは FWの設定

sudo ufw enable
sudo ufw allow 445/tcp
sudo ufw status
sudo ufw reload

Windows側の大切なフォルダを毎日バックアップ

1.バッチファイルを c:\bat\backup.batで作成 バックスラッシュは{¥}で読み替えてね。
タスクスケジューラで実行の為、ドライブ割当、削除記述追加。

@echo off

rem コピー元フォルダ
set src1="C:\大事なフォルダ1"
set src2="C:\大事なフォルダ2"

rem コピー先フォルダ samba共有名指定
set dst="\\192.168.xxx.xxx\lubuntu_disk1"
net use %dst%
set dst1="\\192.168.XXX.XXX\lubuntu_disk1\大事なフォルダ1"
set dst2="\\192.168.XXX.XXX\lubuntu_disk2\大事なフォルダ2"

rem log file フォルダ
set logfolder="C:\log"
set logfile1=%logfolder%"\robocopy1_%date:~0,4%-%date:~5,2%-%date:~8,2%.log"
set logfile2=%logfolder%"\robocopy2_%date:~0,4%-%date:~5,2%-%date:~8,2%.log"

robocopy.exe "%src1%" "%dst1%" /MIR /LOG+:"%logfile1%" /COPY:DAT /R:3 /W:3
robocopy.exe "%src2%" "%dst2%" /MIR /LOG+:"%logfile2%" /COPY:DAT /R:3 /W:3

net use %dst% /delete

スケジュール登録して完了

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?