Back up your files
Walk Space and copy everything out with resumable downloads, on your own schedule.
Why anyone does this
A backup you control is the one that survives a mistake in the place the files live. The requirement is boring and the reason is not: it is the copy you reach for on the worst day.
What a key needs
Grant these and nothing else. A key can never do more than the person who created it, and one that carries only what the job needs is one you can leave running.
The flow
-
Walk the tree
Folders and files, paged, so a large space does not have to fit in one response.
-
Copy what changed
Compare against what you already hold, so a nightly run costs the difference rather than the whole.
-
Resume rather than restart
Downloads honour Range, so a connection dropped at ninety percent costs the last ten and not all of it.
GET
/v1/files/:id/content
The shape of it
Short enough to read in one go, and close enough to run that the gaps are obvious.
# Walk the folders, then the files in each, then pull the bytes.
folders=$(curl -s https://api.veruapis.com/v1/file-folders \
-H "Authorization: Bearer $KEY" | jq -r '.data[].id')
for folder in $folders; do
cursor=""
while :; do
page=$(curl -s "https://api.veruapis.com/v1/files?folder_id=$folder&limit=200&cursor=$cursor" \
-H "Authorization: Bearer $KEY")
echo "$page" | jq -r '.data[] | [.id, .filename, .updated_at] | @tsv' >> manifest.tsv
cursor=$(echo "$page" | jq -r '.meta.next_cursor // empty')
[ -z "$cursor" ] && break
done
done
# Copy only what changed, resuming a dropped transfer rather than restarting it.
while read -r id name updated; do
grep -q "$id $updated" seen.tsv && continue
curl -s -C - -o "backup/$name" "https://api.veruapis.com/v1/files/$id/content" \
-H "Authorization: Bearer $KEY"
echo "$id $updated" >> seen.tsv
done < manifest.tsv
What catches people out
Every one of these came from somebody getting it wrong.
- A backup nobody has restored from is a hypothesis. Restore one at random on a schedule.
- Copying everything nightly will meet the daily quota. Copy the difference.