R
Railwayā€¢8mo ago
BigLung

Database Backup Guide for V2 database?

Howdy, We recently migrated from a v1 database to a v2 instance. The new v2 instance is this project: https://railway.app/project/3644e3a1-b748-46b4-b196-2a94c381d1f0/service/bf6524db-d1f2-41ee-953b-55cba9112421 The backup cron for this service is: https://railway.app/project/ddbced4c-9cfd-4736-9c8b-bfc892c86873/service/fe3ec062-651b-42b8-be7c-6f0981cbd146/variables Unfortunately when I actually check the bucket, these backups dont have any data? I tried loading some of these and they don't actually include any data from my production environment.... Just wondering if the process has changed for v2 backups? Or if I am doing something wrong
Railway
404 - Page not found
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
Railway
404 - Page not found
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
No description
52 Replies
Percy
Percyā€¢8mo ago
Project ID: 3644e3a1-b748-46b4-b196-2a94c381d1f0,bf6524db-d1f2-41ee-953b-55cba9112421,ddbced4c-9cfd-4736-9c8b-bfc892c86873,fe3ec062-651b-42b8-be7c-6f0981cbd146
Brody
Brodyā€¢8mo ago
can you provide your deployment logs for the backup service https://bookmarklets.up.railway.app/log-downloader/
BigLung
BigLungā€¢8mo ago
yes
BigLung
BigLungā€¢8mo ago
maybe that warning? šŸ¤”
Brody
Brodyā€¢8mo ago
you're running an old version of the backup script, do you still have the upstream repo linked to your service?
BigLung
BigLungā€¢8mo ago
Yes let me try updating that and triggering a backup. That will probably resolve the issue but ill come back if it doesn't. Thank you brody! šŸ™‡ā€ā™‚ļø šŸ«¶ classic PEBKAC issue probably šŸ˜„
Brody
Brodyā€¢8mo ago
there was an update?
BigLung
BigLungā€¢8mo ago
Updated the backup script yes redeployed the service, waiting for the cron to trigger now
Brody
Brodyā€¢8mo ago
you can set a run on start variable
BigLung
BigLungā€¢8mo ago
ohh let me do that good idea
Brody
Brodyā€¢8mo ago
RUN_ON_STARTUP
BigLung
BigLungā€¢8mo ago
yup just set and re triggering
BigLung
BigLungā€¢8mo ago
No description
BigLung
BigLungā€¢8mo ago
so I set this variable in the config of the backup cron then I pushed a readme change to our fork of the job to trigger a full redeploy and it doesn't look like it ran?
Brody
Brodyā€¢8mo ago
what does it look like then?
BigLung
BigLungā€¢8mo ago
This is all the deploy logs say now ill try manually running it on my machine
Brody
Brodyā€¢8mo ago
looks like its running an old version, the new version would print the version of both node and pg_dump
BigLung
BigLungā€¢8mo ago
Yup it wasn't running with the code from the PR i just merged. Even after running post PR merge the deploy logs are just completely empty. I'm honestly just gonna delete the service and try reinstantiating from scratch šŸ¤·ā€ā™‚ļø Thank you for your help! Okay I actually got some info!
BigLung
BigLungā€¢8mo ago
redeploying the service from scratch got some good logs gonna look into this šŸ‘Æā€ā™‚ļø
Brody
Brodyā€¢8mo ago
those are good lol?
BigLung
BigLungā€¢8mo ago
error while running backup? im probably dumb haha
Brody
Brodyā€¢8mo ago
last i checked errors arent good šŸ¤£
BigLung
BigLungā€¢8mo ago
I was confused from your comment šŸ¤£
Brody
Brodyā€¢8mo ago
but at least it didnt silently make a 20 byte gzip file in your bucket
BigLung
BigLungā€¢8mo ago
No not good but at least having error messages is progress haha love those 20 bytes kekw
Brody
Brodyā€¢8mo ago
what is the image source of your database?
BigLung
BigLungā€¢8mo ago
GitHub
Build software better, together
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
Brody
Brodyā€¢8mo ago
what tag?
BigLung
BigLungā€¢8mo ago
ghcr.io/railwayapp-templates/timescale-postgis-ssl:pg15-ts2.12
Brody
Brodyā€¢8mo ago
will do some testing and get back to you
BigLung
BigLungā€¢8mo ago
Should I try downgrading that maybe? This fk constraint doesn't actually look like its one of the tables in my schema šŸ¤” Thank you
Brody
Brodyā€¢8mo ago
its just a warning, but the warning is treated as an error, i introduced this bug myself
BigLung
BigLungā€¢8mo ago
lol! šŸ˜„
Brody
Brodyā€¢8mo ago
on one hand the backup will now tell you if there was an error and not upload an empty dump. on the other hand the backup will now yell you if there was a warning and not upload anything.
BigLung
BigLungā€¢8mo ago
interesting are you going to leave this behavior as is? I can try adjusting the script and opening a PR later today maybe?
Brody
Brodyā€¢8mo ago
i already fixed this in a local branch, just not super happy with how its done since pg_dump prints both errors and warnings to stderr theres no super good way to differentiate between a warning and error
BigLung
BigLungā€¢8mo ago
wtf pg dump šŸ˜ 
Brody
Brodyā€¢8mo ago
a command line utility to dump a postgres database
BigLung
BigLungā€¢8mo ago
no I know I just meant
Brody
Brodyā€¢8mo ago
oh lol i see what you mean
BigLung
BigLungā€¢8mo ago
that behavior is kinda wack! sounds like a pain in the ass to deal with
Brody
Brodyā€¢8mo ago
my current error checking code just checks for anything in stderr and throws an error previous code didnt check stderr at all, this is how those empty gzip files where able to make it into s3 in my local branch, i check if stderr has text and the dump is empty and then throw an error, but if stderr has text and the dump isnt empty i print the text in stderr and an extra message that it was likely a warning and to make sure the backup worked
BigLung
BigLungā€¢8mo ago
If possible can I have that current intermediary version of your code that you aren't happy with? Just so that I can get this job up and running for my team while you come up with a clean sexy sollution that you are happy with šŸ¤” ?
Brody
Brodyā€¢8mo ago
no promises it will work, wrote it a while ago and i dont know if i tested it with the postgres image you mentioned above https://github.com/brody192/postgres-s3-backups/tree/fix-foreign-key-constraints
BigLung
BigLungā€¢8mo ago
Thank you testing now šŸ¹
Brody
Brodyā€¢8mo ago
i too will be testing, hopefully i can come to a good solution
Brody
Brodyā€¢8mo ago
it indeed works as intended
BigLung
BigLungā€¢8mo ago
yup forgot to come back and let you know that the changes you sent me worked!!! Thank you šŸ™‡ā€ā™‚ļø
Brody
Brodyā€¢8mo ago
no problem!