Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosRackspace maximizes data center space and compute power with AMD(24.09.2026 um 16:00 Uhr)
Podcasts & Audio BriefingsTechLinked: Android Laptops Are Here…(22.09.2026 um 02:45 Uhr)
Podcasts & Audio BriefingsTechLinked: They’re Really Doing It…(24.09.2026 um 02:56 Uhr)
Podcasts & Audio Briefings9to5Google: Googlebook Hands-On: Android's biggest step in years.(21.09.2026 um 15:00 Uhr)
Podcasts & Audio Briefings9to5Google: 30 days with Pixel 11: What we learned.(22.09.2026 um 17:45 Uhr)
AI & KI NachrichtenNeil Patel: 300 Reviews at 4.2 Beats 15 at 5.0 #shorts(21.09.2026 um 20:03 Uhr)
AI & KI NachrichtenNeil Patel: Google Just Quietly Killed Your Clicks #shorts(22.09.2026 um 20:01 Uhr)
YouTube Security VideosRackspace maximizes data center space and compute power with AMD(24.09.2026 um 16:00 Uhr)
Podcasts & Audio BriefingsTechLinked: Android Laptops Are Here…(22.09.2026 um 02:45 Uhr)
Podcasts & Audio BriefingsTechLinked: They’re Really Doing It…(24.09.2026 um 02:56 Uhr)
Podcasts & Audio Briefings9to5Google: Googlebook Hands-On: Android's biggest step in years.(21.09.2026 um 15:00 Uhr)
Podcasts & Audio Briefings9to5Google: 30 days with Pixel 11: What we learned.(22.09.2026 um 17:45 Uhr)
AI & KI NachrichtenNeil Patel: 300 Reviews at 4.2 Beats 15 at 5.0 #shorts(21.09.2026 um 20:03 Uhr)
AI & KI NachrichtenNeil Patel: Google Just Quietly Killed Your Clicks #shorts(22.09.2026 um 20:01 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Ripristinare il backup di un database PostgreSQL su AWS senza accesso diretto al server DB

In molte infrastrutture AWS ben progettate, il server PostgreSQL non è esposto su Internet: non ha un IP pubblico statico e non è accessibile direttamente via SSH. Il database risiede in una subnet privata all’interno di una VPC, mentre l’…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

In molte infrastrutture AWS ben progettate, il server PostgreSQL non è esposto su Internet:

non ha un IP pubblico statico e non è accessibile direttamente via SSH.



Il database risiede in una subnet privata all’interno di una VPC, mentre l’accesso avviene tramite un server ponte (jump host / bastion host) con IP pubblico.



In questo articolo vediamo come ripristinare un database PostgreSQL partendo da un file .sql presente sul proprio PC, analizzando le diverse soluzioni possibili, i pro e contro, e raccogliendo in fondo una serie di comandi PostgreSQL di uso comune come note operative.







Scenario di riferimento





  • PC locale: Debian Linux, con file db.sql


  • Server ponte: accessibile via SSH con chiave (serverponte.dominioaziendale.it)


  • Server PostgreSQL:




    • Debian

    • IP privato statico (es. serverpostgresql.ipprivato.domioaziendale.it)

    • Accessibile solo dalla VPC




  • Utenti DB disponibili:





    • postgres (superuser)


    • admin (utente applicativo)



  • Obiettivo: ripristinare il database NomeDB da script SQL








Problema tipico



Lo script SQL non viene eseguito correttamente usando DBeaver con l’utente admin e produce errori come:




  • permessi insufficienti

  • impossibilità di creare estensioni

  • errori su OWNER TO postgres

  • messaggi legati a pg_hba.conf



👉 Questo accade perché un file .sql spesso contiene operazioni da superuser, anche se il database esiste già.







Le possibili soluzioni





✔️ Soluzione 1 – Tunnel SSH + psql locale (consigliata)



È la soluzione più pulita, sicura e professionale.

Non richiede di copiare file sui server e sfrutta il port forwarding SSH.





Schema logico





PC locale → tunnel SSH → server ponte → rete privata → PostgreSQL







Apertura del tunnel



Dal PC locale:




ssh -L 5433:serverpostgresql.ipprivato.domioaziendale.it:5432 serverponte.dominioaziendale.it








  • 5433 → porta locale


  • 5432 → porta PostgreSQL remota

  • il tunnel resta attivo finché la sessione SSH è aperta






Ripristino del database



In un secondo terminale locale:




psql -h localhost -p 5433 -U admin -d NomeDB < db.sql






⚠️ In questo scenario l’utente admin deve essere SUPERUSER, altrimenti lo script potrebbe fallire.









✔️ Soluzione 2 – Promuovere temporaneamente admin a superuser



Se pg_hba.conf blocca le connessioni dell’utente postgres da remoto (caso molto comune in ambienti gestiti con Puppet), la soluzione più pragmatica è:




ALTER USER admin WITH SUPERUSER;






Dopo il ripristino:




ALTER USER admin WITH NOSUPERUSER;






✔️ Veloce

✔️ Non richiede modifiche a pg_hba.conf

✔️ Adatta a interventi manuali controllati







✔️ Soluzione 3 – Copiare il file sul server DB ed eseguire localmente



Indicata per file molto grandi o connessioni instabili.




scp db.sql serverponte.dominioaziendale.it:/tmp/
# poi dal jump host verso il DB
scp /tmp/db.sql serverpostgresql.ipprivato.domioaziendale.it:/tmp/






Sul server DB:




su - postgres
psql NomeDB < /tmp/db.sql






✔️ Massima affidabilità

❌ Più passaggi manuali







Perché DBeaver spesso non basta



DBeaver funziona bene per:




  • restore da dump binari

  • operazioni standard

  • utenti applicativi



Ma fallisce con script SQL complessi che contengono:




  • CREATE EXTENSION

  • ALTER OWNER

  • SET ROLE

  • operazioni su schemi di sistema



👉 In questi casi psql è lo strumento giusto.







Note operative – Comandi PostgreSQL di uso comune





Creare un database





CREATE DATABASE NomeDB;







Creare una copia da un database esistente





CREATE DATABASE testCopia WITH TEMPLATE 'NomeDB';







Assegnare tutti i permessi a un utente





GRANT ALL PRIVILEGES ON DATABASE NomeDB TO admin;







Collegarsi a un database con un utente specifico





psql -U admin -d NomeDB -h localhost







Eliminare un database





$ psql -U postgresql -h localhost
DROP DATABASE database_da_eliminare WITH (FORCE);









Backup con pg_dump





Creare un dump SQL





pg_dump -f /tmp/nome_database_dump.sql -U postgres -W nome_database





Significato opzioni:





  • -f → file di output


  • -U postgres → utente DB


  • -W → richiede password


  • nome_database → nome database







Evitare la richiesta password (automazioni)





Metodo consigliato: .pgpass



File ~/.pgpass:




hostname:port:database:username:password






Permessi obbligatori:




chmod 600 ~/.pgpass









Metodo rapido (meno sicuro)






export PGPASSWORD='password'












Ripristino di un database PostgreSQL: scegliere il comando giusto



Il comando da usare per il ripristino dipende dal formato del backup, ovvero da come è stato creato con pg_dump.



È un aspetto fondamentale: usare lo strumento sbagliato porta a errori o a ripristini incompleti.









1️⃣ Ripristino da file SQL (Plain Text)



Se il backup è stato creato senza opzioni di formato (output leggibile, .sql):




pg_dump nome_database > backup.sql






oppure:




pg_dump -f /tmp/pnd_dump.sql nome_database






il ripristino va fatto con psql, che esegue sequenzialmente le istruzioni SQL contenute nel file.




psql -U postgres -d nome_database -f /tmp/nome_database_dump.sql






Note importanti:




  • Il database di destinazione deve già esistere

  • Il file è leggibile e modificabile

  • Su database molto grandi può essere più lento









2️⃣ Ripristino da file Custom o Directory (.dump, .bak)



Se il backup è stato creato con:




pg_dump -Fc nome_database > backup.dump






oppure:




pg_dump -Fd nome_database -f backup_dir






si tratta di un formato binario/speciale, che non può essere eseguito con psql.



In questo caso va usato pg_restore:




pg_restore -U postgres -d nome_database -v backup.dump






Opzioni utili:





  • -v → modalità verbose


  • --clean → elimina gli oggetti prima di ricrearli


  • --if-exists → evita errori se gli oggetti non esistono









Ripristino in parallelo (solo con pg_restore)



Uno dei grandi vantaggi dei formati custom o directory è la possibilità di usare più core CPU:




pg_restore -j 4 -U postgres -d nome_database backup.dump






👉 Ideale per database grandi in ambienti server.









Tabella rapida di riferimento




























Formato backup Strumento Quando usarlo

.sql (plain text)
psql Backup leggibile, semplice

.dump (custom)
pg_restore Backup compresso, selettivo
directory pg_restore Ripristino veloce e parallelo








Nota operativa importante



Se il database di destinazione è già in uso, il ripristino può fallire per:




  • connessioni attive

  • oggetti già esistenti

  • lock sulle tabelle



In questi casi è consigliabile:




  • ripristinare su un database vuoto

  • oppure usare --clean con attenzione









Conclusione



In ambienti AWS con PostgreSQL in subnet private:




  • non si espone mai il DB su Internet

  • il jump host è la chiave

  • psql è lo strumento più affidabile

  • i permessi contano più della GUI



Il tunnel SSH + psql resta la soluzione più solida, ripetibile e sicura per ripristinare database PostgreSQL in infrastrutture cloud ben progettate.

CTI Threat Relationship Graph3 Knoten / 2 Relationen
CVE / Incident Software MITRE ATT&CK CWE Weakness IoC
SOC Incident Playbook: Remote Code Execution (RCE) Defense
title: Detect Exploitation - Ripristinare il backup di un database PostgreSQL su AWS senza accesso diretto al server DB
id: da2748e0-df07-4a09-8f84-fbc3242994b0
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Ripristinare il backup di un d" ascii wide
    condition:
        any of them
}
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Ripristinare il backup di un database Po.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Ripristinare il backup di un database PostgreSQL su AWS senza accesso diretto al server DB

Thematisch verwandte Begriffe: Ripristinare, backup, database, PostgreSQL · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-97360 | HFS2 version 2.4.0 and earlier contains an unauthenticated arbitrary fil…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick