AgentHotel now skips already backed-up agents when it resumes a backup
Chanwoo Song 5 min read

On November 24, an AgentHotel operator upgraded their server during the nightly backup. AgentHotel is a management tool that runs each AI agent in its own container. The backup job was cut off after it had finished five agents. The backup started again 10 minutes later, but it began with the first agent, not the sixth. In that run, one agent was paused for about 12 minutes while its 4.8GB of storage was compressed.
Pull request (PR) #50, merged on November 24 at 8:41 a.m. Central European Time (4:41 p.m. in Korea), makes AgentHotel save its progress each time it finishes backing up one agent. The slow compression and checking steps now run after the agent is restarted.
A record after each agent
In AgentHotel, an agent's sessions and working files live in a volume, a separate storage space that survives container restarts. The nightly backup copies each agent's settings and volume. If an upgrade restarted the process that runs the whole backup, the old approach did not know where to pick up that day's work, even when copies were already on disk. Agents that were copied again ended up with two backups from the same night, each named with a different timestamp.
The new code saves the run's start time, the timestamp used in backup names, and the result for each agent to a database. It does this when the job starts and after each agent is processed. If an interrupted job started no more than 20 hours ago, it continues under the same name. Agents recorded as successful are skipped, and failed agents are tried again. If the job was cut off partway through copying one agent, it does not resume writing that file from the middle. The scheduler can resume not only the nightly automatic backup but also a manual backup that was cut off while running.
A backup counts as successful if a copy was made on the server's disk. If the optional S3 upload then fails, the code logs the upload error separately and keeps the local backup marked as successful. This local success mark is also what decides which agents to skip when a job resumes. So the change does not guarantee that the remote upload is redone for agents whose local backup already finished.
The agent is paused only while its volume is read
If you copy files while an agent is writing them, the files read first and the files read later reflect different moments. The old approach paused the container, then copied the volume and also checked the listing of the compressed file, all while paused. The new code, while the container is paused, creates an uncompressed archive file and records the source's file count, sizes and similar figures. It then restarts the container, compresses the archive it already made, and compares the archive's listing with the source tally it recorded earlier. The compressor does not read the running agent's volume again.

When a maintainer tested the same 4.8GB volume, copying it without compression took 143 seconds, and recording the source's file count, sizes and similar figures took 1.3 seconds. The roughly 12 minutes reported from the earlier run is how long the container was paused. The 143 and 1.3 seconds are measurements of the two steps the change uses. They do not mean the pause in production on the new version drops to exactly 144.3 seconds, or that the whole backup gets faster by that much. Compression and the copy check still happen. With this change, the copy step also needs disk space to hold the uncompressed file.
The values compared are the file count, the total bytes across files, and the number of symbolic links, which point to other files or paths. The check does not confirm that files of the same size also have the same contents. Instead, only local copies that pass this tally count toward the retention limit. This stops an unverified copy left behind by an interruption from taking a recent-backup slot and pushing out the last verified copy.
Backup time is not the time an agent was paused
The merged code adds records that log, for each agent, the time spent paused, copying and compressing, checking, and uploading to remote storage. Some steps overlap, so these values are not meant to be added up into a total backup time. Still, on a day when the whole job runs long, you can tell apart the time users got no answer from the time the server kept working after the container came back. The notice shown when an upgrade overlaps with a backup now also says which agent in the sequence is being processed.
I ran the 10 backup tests on this code and confirmed that all of them passed. Three of them are new. They check resuming an interrupted job, records that must not be resumed, and how unverified copies are kept. This is not a result from a restore with real containers and remote storage attached, or from a new measurement of production timing on the 4.8GB volume. The public release list did not show a separate version tag when I checked.
OpenAI's review of ChatGPT speed was the subject of a post where I wrote that you can only see what to fix after you split up where the slowdown happens. Running agents works the same way. A record that only says the nightly job took a long time does not tell you how long an agent went without answering the next morning, or which agent the backup needs to restart from. With this change, you can check how far the backup got for each agent and how long each agent was actually paused.