ChatGPT 🤮 No, glorified autocomplete which needs hundreds of Watt-hours to come up with unreliable bollocks is definitely not the way to go about it. Let's instead use some power-efficient (33W TDP) hardware optimised for complex problem solving. Yeah, that's our brains right in our head.
As per the fine manual you can't really do what you want to do. UNiTE expects a filename. It cannot magically know your archive naming organisation and nomenclature which is necessary to determine what is the latest backup. So, we need to download that latest backup with a name UNiTE can recognise, and then tell UNiTE to restore it.
Therefore, we have these discrete steps:
- Find my latest backup.
- Download my latest backup.
- Restore my latest backup.
Before we go ahead, let's note that since this is a matter of automation we want to use command line tools only. You could use AWS' own CLI but it's rather cumbersome since it's meant to work with all of AWS' services. Instead, we're gonna use s3cmd which is S3-specific, very easy to use, and very fast indeed. If you have not set it up already, go ahead and do it. I will assume it's accessible as s3cmd
from your command line.
Find my latest backup
BACKUP_FILENAME=`s3cmd ls s3://my-bucket/site-www.example.com-* | grep .jpa | tail -1 | awk '{print $4}'`
This looks into the bucket my-bucket
for any file whose name starts with site-www.example.com-*
and prints them alphabetically. Since our naming convention is site-[HOST]-[DATE]-[TIME] alpha sorting is also time sorting.
In case we have multiple parts per backup we use grep .jpa
to only fetch the .jpa files from our listing.
We then use tail -1
to only return the latest entry which looks like this:
2024-02-05 01:10 700550664 s3://my-bucket/site-www.example.com-20240204-190002cst.jps
Therefore we use awk
to only return the fourth field, which is the filename.
Download my latest backup
s3cmd --skip-existing --no-check-md5 get $BACKUP_FILENAME
As simple as that. Now we get the latest backup file back from S3.
If it's a multipart archive we'll need to do a simple loop to iterate through extensions j01, j02 etc until we get an error.
Restore my latest backup
To restore the backup, we need it to have a predictable filename. So:
mv $(basename $BACKUP_FILENAME) site.jpa
Now we can have our UNiTE file always try to restore site.jpa.
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!