jeefski
jeefski
RRailway
Created by jeefski on 1/15/2024 in #✋|help
Database migration data backup (attempt 2)
#!/bin/bash

# Define the PostgreSQL credentials and backup file information
PGUSER=""
PGHOST=""
PGPORT=""
PGDATABASE=""

# Generate a timestamp in the format yyyy-mm-dd-hh-mm
TIMESTAMP=$(date +"%Y-%m-%d-%H-%M")

# Define the backup file name with the timestamp
BACKUP_FILENAME="backup_$TIMESTAMP.tar"

# Prompt for the database password
echo "Please enter the PostgreSQL password:"
read -s PGPASSWORD

# Export the password to be used by pg_dump
export PGPASSWORD

# Execute the pg_dump command
pg_dump -U $PGUSER -h $PGHOST -p $PGPORT -W -F t $PGDATABASE > $BACKUP_FILENAME

# Unset the password for security reasons
unset PGPASSWORD

echo "Backup completed successfully."
#!/bin/bash

# Define the PostgreSQL credentials and backup file information
PGUSER=""
PGHOST=""
PGPORT=""
PGDATABASE=""

# Generate a timestamp in the format yyyy-mm-dd-hh-mm
TIMESTAMP=$(date +"%Y-%m-%d-%H-%M")

# Define the backup file name with the timestamp
BACKUP_FILENAME="backup_$TIMESTAMP.tar"

# Prompt for the database password
echo "Please enter the PostgreSQL password:"
read -s PGPASSWORD

# Export the password to be used by pg_dump
export PGPASSWORD

# Execute the pg_dump command
pg_dump -U $PGUSER -h $PGHOST -p $PGPORT -W -F t $PGDATABASE > $BACKUP_FILENAME

# Unset the password for security reasons
unset PGPASSWORD

echo "Backup completed successfully."
17 replies
RRailway
Created by jeefski on 1/15/2024 in #✋|help
Database migration data backup (attempt 2)
I got ChatGPT to write me a simple script 😆 :
17 replies
RRailway
Created by jeefski on 1/15/2024 in #✋|help
Database migration data backup (attempt 2)
Variables seem to be in the console. Will give it a shot.
17 replies
RRailway
Created by jeefski on 1/15/2024 in #✋|help
Database migration data backup (attempt 2)
Thanks, I'll investigate that. Looks like I can just follow this and connect to the remote host/DB: https://blog.railway.app/p/postgre-backup
17 replies
RRailway
Created by jeefski on 1/15/2024 in #✋|help
Database migration data backup (attempt 2)
OK, thank you. What is the easiest way to do an offsite backup in any case? My project ID is if still needed: 52d66897-89e5-45a0-b983-517609e05c8c
17 replies