You could make 2 scripts:
One that downloads the stats to your local db.
One that deletes the new records it finds in your local db from your
db, that way you’re sure nothing gets deleted from the online/remote db
unless it really exists in your local db.
That’s how I’d do it (not really fancy, I know…)