# server-befehle ## Festplattenverbrauch ermitteln: ``` df -h ``` ### du (Disk Usage) ``` du /home/ ``` https://www.tecmint.com/check-linux-disk-usage-of-files-and-directories/ ### ncdu (CLI-based) ``` sudo apt install ncdu ncdu ``` ## rsync Rsync ohne Rechteübernahme (gut für gemountete Laufwerke SAMBA) ``` sudo rsync -rltv --exclude '/storage/tzm_de/var/lib/nextcloud/*' /storage/ /mnt/backup-storage/ ``` ### Hetzner ``` # Push rsync --progress -e 'ssh -p23' --recursive @.your-storagebox.de: # Pull rsync --progress -e 'ssh -p23' --recursive @.your-storagebox.de: # Als Bash-Skript lieber im verbose statt mit progress und Löschen aller Dateien am Ziel, wenn in Quelle nicht mehr vorhanden. rsync -v --delete -e 'ssh -p23' --recursive @.your-storagebox.de: ``` https://wiki.hetzner.de/index.php/Storage_Boxes * --progress = Alle Dateien und deren Datentransfer anzeigen * --delete = Alle Dateien beim Ziel löschen, wenn sie bei der Quelle auch nicht mehr vorhanden sind * --recursive = Alle Unterverzeichnisse mit einbeziehen * -v = Versbose-Mode * -e = alternatives Protokoll bspw. `-e 'ssh'` Häufig verwendete Befehle: https://linuxconcept.com/rsync-example-for-system-administrator/ Alle Optionen: https://wiki.ubuntuusers.de/rsync/ ## Cronjob ### QNAP **Do NOT edit crontab the usual way!** `crontab -e` However, due to the way the QNAP firmware updates crontab, it will be overwritten on the next reboot. Obviously, you want your automation to survive reboots, so edit the crontab file directly with your text editor: ``` vim /etc/config/crontab ``` When you're done, reload the crontab file and restart the cron daemon: ``` crontab /etc/config/crontab && /etc/init.d/crond.sh restart ``` https://wiki.qnap.com/wiki/Add_items_to_crontab ## Gute Quellen * Bash-Skripte: https://wiki.ubuntuusers.de/Shell/Bash-Skripting-Guide_für_Anfänger/ * Cronjobs: https://www.stetic.com/developer/cronjob-linux-tutorial-und-crontab-syntax.html