Restauração de Backups
Este guia mostra como restaurar dados de backups.
Listar Backups Disponíveis
Por Task
backupally history --target mysql-prodSaída:
SNAPSHOT DATE SIZE STATUS
snap_20260211_020000 2026-02-11 02:00:00 890 MB OK
snap_20260210_020000 2026-02-10 02:00:00 885 MB OK
snap_20260209_020000 2026-02-09 02:00:00 882 MB OKTodos os Backups
backupally historyFiltrar por Data
backupally history --target mysql-prod --since 2026-02-01 --until 2026-02-10Restaurar Backup
Sintaxe
backupally restore \
--target <TASK_ID> \
--snapshot <SNAPSHOT_ID> \
--path <DESTINO>Exemplo Básico
backupally restore \
--target mysql-prod \
--snapshot snap_20260211_020000 \
--path /restore/mysqlVerificar Integridade
Antes de restaurar, verifique o backup:
backupally restore \
--target mysql-prod \
--snapshot snap_20260211_020000 \
--verifySimulação (Dry Run)
Veja o que seria restaurado sem extrair:
backupally restore \
--target mysql-prod \
--snapshot snap_20260211_020000 \
--path /restore \
--dry-runRestaurar com Chave Específica
Se o backup foi feito com outra chave:
backupally restore \
--target mysql-prod \
--snapshot snap_20260211_020000 \
--path /restore \
--key /etc/backupally/keys/old-key.pemRestaurar Databases
MySQL
- Restaure os arquivos:
backupally restore \
--target mysql-prod \
--snapshot snap_20260211_020000 \
--path /restore/mysql- Importe no MySQL:
# Banco específico
mysql -u root -p myapp < /restore/mysql/myapp.sql
# Todos os bancos
for f in /restore/mysql/*.sql; do
mysql -u root -p < "$f"
donePostgreSQL
- Restaure os arquivos:
backupally restore \
--target postgres-prod \
--snapshot snap_20260211_030000 \
--path /restore/postgres- Importe no PostgreSQL:
# Criar banco se necessário
createdb -U postgres myapp_restored
# Restaurar globals (roles)
psql -U postgres -f /restore/postgres/globals.sql
# Restaurar banco
psql -U postgres -d myapp_restored -f /restore/postgres/myapp.sqlMongoDB
- Restaure os arquivos:
backupally restore \
--target mongodb-prod \
--snapshot snap_20260211_020000 \
--path /restore/mongodb- Importe no MongoDB:
mongorestore /restore/mongodb/Com opções:
mongorestore --drop --gzip /restore/mongodb/Restaurar Arquivos
Para Diretório Temporário
backupally restore \
--target website \
--snapshot snap_20260211_040000 \
--path /restore/websitePara Local Original
backupally restore \
--target website \
--snapshot snap_20260211_040000 \
--path /var/www/htmlArquivo Específico
Atualmente, BackupAlly restaura o backup completo. Para extrair arquivo específico:
# Restaure para temp
backupally restore --target website --snapshot snap_xxx --path /tmp/restore
# Copie o arquivo desejado
cp /tmp/restore/var/www/html/config.php /var/www/html/
# Limpe
rm -rf /tmp/restoreRecovery de Chaves
Usando Servidor Central
Se configurado:
backupally keys recover \
--fingerprint a1b2c3d4e5f6a7b8 \
--server https://central.backupally.io \
--api-key your-key \
--output /etc/backupally/keys/recovered.keyIdentificar Chave Necessária
O fingerprint está no header do backup:
backupally inspect snap_20260211_020000.allyTroubleshooting
Erro: Chave Inválida
Error: Failed to decrypt: Invalid keyO backup foi feito com outra chave. Use --key para especificar.
Erro: Snapshot Não Encontrado
Error: Snapshot not foundVerifique se o snapshot existe:
backupally history --target mysql-prodErro: Checksum Inválido
Error: Checksum mismatchO arquivo pode estar corrompido. Tente outro storage:
backupally restore \
--target mysql-prod \
--snapshot snap_xxx \
--path /restore \
--storage b2-secondaryErro: Espaço Insuficiente
Verifique espaço antes de restaurar:
df -h /restoreBoas Práticas
- Teste restaurações regularmente: Não espere um desastre
- Mantenha chaves seguras: Sem chave, backups são inúteis
- Documente fingerprints: Saiba qual chave usar para cada backup
- Restaure para local temporário: Verifique antes de sobrescrever
- Verifique integridade: Use
--verifyantes de restaurar
By Borlot.com.br on 11/02/2026