simple.sh (2183B)
1 #!/bin/bash 2 3 # ======== BOOLEANS TO SYNC ======== 4 5 # backup laack.co vps 6 BACKUP_VPS=true 7 # backup brgr 8 BACKUP_SRV=true 9 # sync personal-files from brgr ~ 10 SYNC_SHARED_DIR=true 11 12 13 HOSTNAME_BRGR=$(hostnamectl | grep brgr) 14 15 16 if [ -n "$HOSTNAME_BRGR" ]; then 17 # BACKUP_SRV=false 18 SYNC_SHARED_DIR=false 19 fi 20 # commented because I like being able to tar + gpg /home/backup 21 22 # ======== SOURCES OF TRUTH ======== 23 24 # Where should data be saved? 25 26 # 1. Git (public | private) 2. Sync Directory 27 # 28 # Git 29 # - **non-binary** data should in git repos. 30 # - private: 31 # - these live at brgr:/srv/git/private-repos/ 32 # - public: 33 # - these live at root@laack.co:/srv/git/ 34 # Sync directory 35 # - brgr:~/personal-files 36 # - this is where music, videos, photos, and large encrypted data should live 37 # 38 # Backups should be of /srv/ on brgr and /srv/git on the vps. 39 # 40 # Synced data should be in ~/personal-files. These don't really require backups because they 41 # are just nice to have on all systems. 42 43 44 # ======== BACKUP DEFINITIONS ======== 45 46 backup-vps () { 47 48 # this contains my matrix server db stuff (sqlite) 49 50 mkdir -p /home/backup/vps/var 51 rsync -v --delete --recursive \ 52 --exclude='/lib/containers/' \ 53 --exclude='/lib/docker/' \ 54 --exclude='/log/' \ 55 root@laack.co:/var/ /home/backup/vps/var 56 57 # TODO: Consider refactoring this. This sort of breaks with convention, but there is 58 # nginx configuration data here that is a source of truth... 59 60 mkdir -p /home/backup/vps/etc 61 rsync -v --delete --recursive root@laack.co:/etc/ /home/backup/vps/etc 62 63 mkdir -p /home/backup/vps/srv 64 rsync -v --delete --recursive root@laack.co:/srv/ /home/backup/vps/srv 65 } 66 67 68 backup-srv() { 69 # backup private git repos + any additional things in srv (shouldn't be for now) 70 mkdir -p /home/backup/brgr/srv 71 rsync -v --delete --recursive andrew@brgr:/srv/ /home/backup/brgr/srv 72 } 73 74 sync-shared() { 75 rsync -v --delete --recursive andrew@brgr:/home/andrew/personal-files ~ 76 } 77 78 79 if [ $BACKUP_VPS == "true" ]; then 80 backup-vps 81 fi 82 83 if [ $BACKUP_SRV == "true" ]; then 84 backup-srv 85 fi 86 87 if [ $SYNC_SHARED_DIR == "true" ]; then 88 sync-shared 89 fi