server-befehle/README.md

59 lines
2.1 KiB
Markdown
Raw Normal View History

2019-09-23 07:36:52 +00:00
# server-befehle
2019-09-23 07:45:12 +00:00
## Festplattenverbrauch ermitteln:
2019-09-23 07:39:21 +00:00
```
df -h
```
2019-09-23 07:45:12 +00:00
### 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
2019-09-23 07:39:21 +00:00
Rsync ohne Rechteübernahme (gut für gemountete Laufwerke SAMBA)
```
sudo rsync -rltv --exclude '/storage/tzm_de/var/lib/nextcloud/*' /storage/ /mnt/backup-storage/
```
2019-09-23 19:17:53 +00:00
### Hetzner
```
2019-09-24 17:15:18 +00:00
# Push
2019-09-23 19:17:53 +00:00
rsync --progress -e 'ssh -p23' --recursive <Lokales Verzeichnis> <Benutzername>@<Benutzername>.your-storagebox.de:<Ziel Verzeichnis>
2019-09-24 17:15:18 +00:00
# Pull
2019-09-23 19:17:53 +00:00
rsync --progress -e 'ssh -p23' --recursive <Benutzername>@<Benutzername>.your-storagebox.de:<Verzeichnis> <Lokales Verzeichnis>
2019-09-24 18:05:42 +00:00
# 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 <Benutzername>@<Benutzername>.your-storagebox.de:<Verzeichnis> <Lokales Verzeichnis>
2019-09-23 19:17:53 +00:00
```
https://wiki.hetzner.de/index.php/Storage_Boxes
2019-09-23 07:39:21 +00:00
2019-09-24 17:15:18 +00:00
* --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'`
2019-09-24 20:32:37 +00:00
Häufig verwendete Befehle: https://linuxconcept.com/rsync-example-for-system-administrator/
Alle Optionen: https://wiki.ubuntuusers.de/rsync/
2019-09-24 18:04:33 +00:00
2019-09-23 19:21:37 +00:00
## Cronjob
### QNAP
2019-09-23 19:23:21 +00:00
**Do NOT edit crontab the usual way!** `crontab -e`
2019-09-23 19:21:37 +00:00
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
```
2019-09-23 19:22:22 +00:00
When you're done, reload the crontab file and restart the cron daemon:
```
crontab /etc/config/crontab && /etc/init.d/crond.sh restart
```
2019-09-23 19:24:01 +00:00
https://wiki.qnap.com/wiki/Add_items_to_crontab
2019-09-23 07:39:21 +00:00
## 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