Proxmox-Backup Restore: Difference between revisions
Initial |
spelling and using pre and cats Tag: 2017 source edit |
||
Line 2: | Line 2: | ||
= Proxmox Backup and Restore = | = Proxmox Backup and Restore = | ||
This guide aims to provide options for consistently | This guide aims to provide options for consistently Backing up a server, some instructions, and best practices for restoring from backup, and testing backups prior to needing them. | ||
Back to [[Server_Guides]] | |||
<span id="assumptions"></span> | <span id="assumptions"></span> | ||
Line 9: | Line 11: | ||
This guide focuses on proxmox servers and assumes a directory is established on that server for backups. | This guide focuses on proxmox servers and assumes a directory is established on that server for backups. | ||
In this case we use /datadrive/Backups/ | In this case, we use /datadrive/Backups/ | ||
This guide also assumes that services | This guide also assumes that services run within containers and VMs on the proxmox server (host) and that SSH keys have been established and copied into each VM and container. [[ssh-keys.md|ssh-keys]] covers more on ssh key generation and usage. ## Individual Guides See individual guides here: [[Authentik-Backup.md|Authentik-Backup]] | ||
<span id="backup"></span> | <span id="backup"></span> | ||
== Backup == | == Backup == | ||
< | <pre>#!/bin/bash | ||
#/usr/local/bin/proxmox-backup.sh | #/usr/local/bin/proxmox-backup.sh | ||
= Define variables = | = Define variables = | ||
Line 50: | Line 52: | ||
echo "Remote backup completed successfully." | echo "Remote backup completed successfully." | ||
= sync from authentik server to proxmox backup = | = sync from authentik server to proxmox backup = | ||
rsync -avz --progress $AUTHENTIK_REMOTE_USER@$AUTHENTIK_REMOTE_HOST:$AUTHENTIK_REMOTE_BACKUP_DIR $LOCAL_BACKUP_DIR/authentik_backups</ | rsync -avz --progress $AUTHENTIK_REMOTE_USER@$AUTHENTIK_REMOTE_HOST:$AUTHENTIK_REMOTE_BACKUP_DIR $LOCAL_BACKUP_DIR/authentik_backups</pre> | ||
<span id="restore"></span> | <span id="restore"></span> | ||
== Restore == | == Restore == | ||
[[Category:Self-hosting]] | |||
[[Category:Guides]] |
Revision as of 04:17, 22 September 2024
Proxmox Backup and Restore
This guide aims to provide options for consistently Backing up a server, some instructions, and best practices for restoring from backup, and testing backups prior to needing them.
Back to Server_Guides
Assumptions
This guide focuses on proxmox servers and assumes a directory is established on that server for backups.
In this case, we use /datadrive/Backups/
This guide also assumes that services run within containers and VMs on the proxmox server (host) and that SSH keys have been established and copied into each VM and container. ssh-keys covers more on ssh key generation and usage. ## Individual Guides See individual guides here: Authentik-Backup
Backup
#!/bin/bash #/usr/local/bin/proxmox-backup.sh = Define variables = BACKUP_DIR="/datadrive/Backups" VZ_DIR="/var/lib/vz/dump" BACKUP_REMOTE="pcloud:Backups/Server-Backups" VZ_REMOTE="pcloud:Backups/Server-Backups/VZDUMPS" LOCAL_BACKUP_DIR="/datadrive/Backups" = Authentik variables = AUTHENTIK_REMOTE_USER="root" AUTHENTIK_REMOTE_HOST="192.168.4.134" AUTHENTIK_REMOTE_BACKUP_DIR="/home/authentik/authentik/authentik_backups" TIMESTAMP=$(date +"%Y%m%d%H%M%S") = Ensure remote backup directory exists = ssh $AUTHENTIK_REMOTE_USER@$AUTHENTIK_REMOTE_HOST "mkdir -p $AUTHENTIK_REMOTE_BACKUP_DIR" = Backup PostgreSQL Database = ssh $AUTHENTIK_REMOTE_USER@$AUTHENTIK_REMOTE_HOST "docker exec -i authentik-postgresql-1 /usr/local/bin/pg_dump --username authentik authentik > $AUTHENTIK_REMOTE_BACKUP_DIR/postgres-back" = Save Redis Database = ssh $AUTHENTIK_REMOTE_USER@$AUTHENTIK_REMOTE_HOST "docker exec -i authentik-redis-1 redis-cli save" = Copy Redis Dump = ssh $AUTHENTIK_REMOTE_USER@$AUTHENTIK_REMOTE_HOST "docker cp authentik-redis-1:/data/dump.rdb $AUTHENTIK_REMOTE_BACKUP_DIR/redis-backup-$TIMESTAMP.rdb" = Create Tarball of Necessary Files = ssh $AUTHENTIK_REMOTE_USER@$AUTHENTIK_REMOTE_HOST "tar czvf $AUTHENTIK_REMOTE_BACKUP_DIR/authentik-backup-$TIMESTAMP.tar.gz -C /home/authentik/authentik authentik docker-compose.yml certs" #create encrypted dir with all these matching that timestamp echo "Remote backup completed successfully." = sync from authentik server to proxmox backup = rsync -avz --progress $AUTHENTIK_REMOTE_USER@$AUTHENTIK_REMOTE_HOST:$AUTHENTIK_REMOTE_BACKUP_DIR $LOCAL_BACKUP_DIR/authentik_backups