Fileserver
Der Fileserver ist ein LXC-Container in Proxmox. Die ID lautet 103. Der LXC wurde als Privileged installiert, damit er auf die Ressource zfs - Daten und zfs - Data zugreifen darf.
Samba-File
nano /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
; interfaces = 127.0.0.0/8 eth0
; bind interfaces only = yes
log file = /var/log/samba/log.%m
max log size = 1000
logging = file
panic action = /usr/share/samba/panic-action %d
server role = standalone server
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
; logon path = \\%N\profiles\%U
; logon drive = H:
; logon script = logon.cmd
; add user script = /usr/sbin/useradd --create-home %u
; add machine script = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u
; add group script = /usr/sbin/addgroup --force-badname %g
; include = /home/samba/etc/smb.conf.%m
; idmap config * : backend = tdb
; idmap config * : range = 3000-7999
; idmap config YOURDOMAINHERE : backend = tdb
; idmap config YOURDOMAINHERE : range = 100000-999999
; template shell = /bin/bash
usershare allow guests = yes
#[homes]
# comment = Home Directories
# browseable = no
# read only = yes
# create mask = 0700
# directory mask = 0700
# valid users = %S
;[netlogon]
; comment = Network Logon Service
; path = /home/samba/netlogon
; guest ok = yes
; read only = yes
;[profiles]
; comment = Users profiles
; path = /home/samba/profiles
; guest ok = no
; browseable = no
; create mask = 0600
; directory mask = 0700
[printers]
comment = All Printers
browseable = no
path = /var/tmp
printable = yes
guest ok = no
read only = yes
create mask = 0700
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = no
; write list = root, @lpadmin
[Freigabe]
path = /mnt/samba_data
browseable = yes
read only = no
guest ok = no
create mask = 0666
directory mask = 0777
force user = root
vfs objects = recycle
recycle:repository = .recycle
recycle:keeptree = yes
recycle:versions = yes
recycle:repository_chmod = 0777
recycle:directory_mode = 0777
recycle:exclude = *.tmp, *.temp, ~$*, *.bak
recycle:touch = yes
recycle:maxsize = 0
Skripte:
Werden in Autostart eingetragen
crontab -e
0 0 * * 0 /usr/local/bin/empty_recycle.sh
00 02 * * * /usr/local/bin/samba_backup.sh
Backup
#!/bin/bash
# --- KONFIGURATION ---
SOURCE="/mnt/samba_data/"
TARGET="/mnt/backup/daily_mirror/"
LOGFILE="/var/log/samba_backup.log"
# Verzeichnis auf dem Backup-Pool erstellen, falls nicht vorhanden
mkdir -p "$TARGET"
echo "--- Backup gestartet: $(date) ---" >> "$LOGFILE"
# rsync Erklärung:
# -a: Archiv-Modus (erhält Zeiten, Rechte, etc.)
# -v: Zeigt an, welche Dateien kopiert werden
# --delete: Löscht Dateien im Backup, die in der Quelle nicht mehr da sind (echte Spiegelung)
# --exclude: Den Papierkorb nicht mit ins Backup sichern
rsync -av --delete --exclude='.recycle' "$SOURCE" "$TARGET" >> "$LOGFILE" 2>&1
echo "--- Backup beendet: $(date) ---" >> "$LOGFILE"
echo "----------------------------------------" >> "$LOGFILE"
Papierkorb löschen
#!/bin/bash
# Löscht alles im Papierkorb, was älter als 30 Tage ist
find /mnt/samba_data/.recycle/ -type f -mtime +30 -delete
# Löscht leere Ordner im Papierkorb
find /mnt/samba_data/.recycle/ -type d -empty -delete