Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task: Set up new main.py to run on the VM #1045

Open
3 tasks
nlebovits opened this issue Dec 11, 2024 · 1 comment
Open
3 tasks

Task: Set up new main.py to run on the VM #1045

nlebovits opened this issue Dec 11, 2024 · 1 comment

Comments

@nlebovits
Copy link
Collaborator

Describe the task

We need to get the new pipeline running on the VM. In order to do this, you'll need to update the .cagp_env file appropriately, build the new docker container, and update the CRON job to run main.py once a month. We'll also want to create monthly backups (or maybe quarterly backups?) of the database. We'll need to make sure all of our slack messages are reporting correctly for monitoring purposes, and that the data are being written to the right place in GCP to be usable by the website. Since we have the data in hypertables now, I don't think we need to be as concerned about backup up the pmtiles, but we should still due our due dilligence to make sure we're not deleting things. I've backed up the old postgres database to GCP inccase something happens.

Note: I know this ticket needs to be improved. Please throw a comment on here if you're interested and I'll come back with more context.

Acceptance Criteria

  • first
  • second
  • third

Additional context

Here's a shell script you modify as the basis of your pg_dump backups:

#!/bin/bash

# Set variables
TIMESTAMP=$(date +"%Y%m%d_%H%M%S") # Current timestamp
DB_NAME="vacantlotdb"             # Replace with your database name
DB_USER="postgres"                # Replace with your database username
DOCKER_CONTAINER="cagp-postgres"  # Replace with your PostgreSQL Docker container name
BACKUP_FILE="vacantlotdb_backup_$TIMESTAMP.sql.gz"
BUCKET="gs://cleanandgreenphl/db_backups"

# Dump the database using Docker and compress the output
echo "Starting database backup..."
docker exec $DOCKER_CONTAINER pg_dump -U $DB_USER -d $DB_NAME | gzip > /tmp/$BACKUP_FILE

# Upload the backup to GCS
echo "Uploading backup to Google Cloud Storage..."
gsutil cp /tmp/$BACKUP_FILE $BUCKET

# Verify upload success
if [ $? -eq 0 ]; then
  echo "Backup uploaded successfully."
  # Remove local backup file to save space
  rm /tmp/$BACKUP_FILE
else
  echo "Failed to upload backup to GCS."
  exit 1
fi

echo "Monthly database backup completed successfully."
@nlebovits
Copy link
Collaborator Author

@rmartinsen if you're interested in tackling another issue, this would be a huge help (same as with #1046). I'm traveling this week and don't have bandwidth to make this happen--any chance you're interested?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant