---
title: 'Never lose robot data again: automatic ROS 2 bag recording and upload'
description: 'If you work with robots, perhaps you’ve come up against a common, but
  annoying situation: the one field run that mattered is the one nobody recorded.
  Or it was recorded but the ROS 2 bag (a recording of ROS 2 topics) is sitting in
  the robot’s storage, at a customer site, three time zones away.  […]'
url: https://canonical.com/blog/never-lose-robot-data-again-automatic-ros-2-bag-recording-and-upload
---

1. [Blog](https://canonical.com/blog)
2. Article

---

[gbeuzeboc](https://canonical.com/blog/author/gbeuzeboc "More about gbeuzeboc")

3 November 2026

# Never lose robot data again: automatic ROS 2 bag recording and upload

[ROS 2](https://canonical.com/blog/tag/ros-2)

---

Share the article

If you work with robots, perhaps you’ve come up against a common, but annoying situation: the one field run that mattered is the one nobody recorded. Or it was recorded but the ROS 2 bag (a recording of ROS 2 topics) is sitting in the robot’s storage, at a customer site, three time zones away.

This issue is commonly caused by manually starting ros2 bag record and using `scp` to copy gigabytes off the robot after every test, which just does not scale. It can also lead to missing bag synchronizations or accidental overwrites.

There is a better way: let every robot record itself continuously and upload its bags to your server automatically. That is exactly what the [`ros2-exporter-agent`](https://snapcraft.io/ros2-exporter-agent) snap does.

## What can the `ros2-exporter-agent` do?

The snap runs four small cooperating services on the robot:

* **recorder**: records your ROS 2 topics to [MCAP bags](https://mcap.dev/), splitting them by time or size
* **synchronization**: every two minutes, this service attempts to upload bag files with [rclone](https://rclone.org/)
* **daily-rotation**: restarts recording at midnight so bags are grouped in clean, timestamped sets
* **auto-clean**: deletes local files older than 10 minutes, so the disk does not fill up with old bags. Bags live locally only as a short staging buffer

The design was built with safety in mind: recording only starts once auto-clean is running, and the sync service retries automatically. If the server is briefly unreachable, the robot retries the upload automatically.

## A server setup for every team

The server itself can live wherever it makes sense for you: a machine on the local network, right where the robots operate, a self-hosted server back at your office, or simply a cloud server.

The upload side is plain rclone, which supports [more than 40 storage backends](https://rclone.org/docs/#configure). The snap always uploads to an rclone remote called bagstore independently of the configure backend. Switching from a lab server to AWS S3 is a configuration change away.

You can find below two examples of rclone configurations for the ros2-exporter-agent.

A simple SSH-accessible server (SFTP backend):

```
[fileserver]
type = sftp
host = bags.robot-company.com
user = robot
port = 22
key_file = /root/snap/ros2-exporter-agent/common/device_rsa_key

[bagstore]
type = alias
remote = fileserver:/srv/bags/robot-01
```

An S3-compatible bucket (AWS, Ceph, MinIO…):

```
[s3store]
type = s3
provider = Ceph
access_key_id = <access-key>
secret_access_key = <secret-key>
endpoint = https://s3.robot-company.com

[bagstore]
type = alias
```

Notice the pattern: the first section is backend-specific, but the `bagstore` alias never changes. Whether you manage one robot or a hundred with SSH or S3, the snap logic stays identical.

## Set up a robot in a few minutes

Getting started takes one command and two configuration files:

```
sudo snap install ros2-exporter-agent --channel latest/candidate
```

On installation, the snap creates two templates in `/var/snap/ros2-exporter-agent/common/local-configuration/`.

Rename them to remove the .template suffix, then edit them:

* `rclone.conf` describes where bags go using any of the backends above
* `rosbag2-recorder.yaml` describes what to record, which topics to include or exclude, and how often to split bag files

The [configuration section of the snap’s README](https://github.com/canonical/ros2-exporter-agent#configuration) documents both formats with examples.

Once both files are in place, the services pick them up and the robot starts recording and uploading on its own.

## Central configuration for a fleet

Editing files on each robot works up to a certain point. However,  the snap also offers options for  managing fleets. In this case, the snap also reads its configuration through a [content interface](https://snapcraft.io/docs/content-interface). A separate configuration snap holds `rclone.conf` and `rosbag2-recorder.yaml`, and any robot that connects to it gets the same setup. This automates away much of the manual editing.

The [rob-cos-demo-configuration](https://github.com/canonical/rob-cos-demo-configuration) repository is a ready-made example, with a ‘`basic`‘ branch (SFTP file server) and an ‘`advanced`‘ branch (S3-compatible storage).

The configuration snap also integrates some automations, such as generating a UID per device and applying the UID to the configuration. Such automations could inspire you for your own fleet.

Fork it, adapt the configuration to your own server details, build your own configuration snap, and every robot that plugs in is configured identically. By updating the configuration once, the whole fleet will receive the update.

## Ideas to take it further

Once you start saving bags from your fleet, you might want to take it further with additional integrations:

* **Pull a bag to your laptop**: use a small wrapper around `rclone` copy (or a shared alias/script) so any engineer can grab yesterday’s bag from `robot-07` with one command.
* **Browse bags in a web viewer**: place a lightweight file browser in front of the storage, so anyone can find and download bags from a browser.
* **Open bags straight from storage**: tools like [Foxglove](https://snapcraft.io/foxglove-studio) can load a remote MCAP file by URL, so you can start inspecting a bag without downloading it first.

## Further reading

* [Bring zenoh to ROS 2 with snaps](https://canonical.com/blog/bring-zenoh-to-ros-2-with-snaps)
* [ROS Noetic is EoL, take actions to maintain fleet security](https://canonical.com/blog/ros-noetic-is-eol-take-action-to-maintain-fleet-security)
* [ROS development on Linux, Windows and MacOS](https://canonical.com/blog/ros-development-on-linux-windows-and-macos)

[Get in touch

Interested in running Ubuntu in your organization?](https://ubuntu.com/about/contact-us/form)

## Sign up for our newsletter

Get the latest Canonical news and updates in your inbox.

Work email:

\*I agree to receive information about Canonical's
products and services.

In submitting this form, I confirm that I have read and agree to
[Canonical's Privacy Notice](https://canonical.com/legal/data-privacy/contact)
and [Privacy Policy](https://canonical.com/legal/data-privacy).

Sign up

## Share on

---

## Related posts

[### Bring Zenoh to ROS 2 with snaps](https://canonical.com/blog/bring-zenoh-to-ros-2-with-snaps)

ROS 2 gives robotics developers the freedom to choose the middleware that fits their system. As a communication protocol for ROS, Zenoh has gained strong traction. It delivers...

[gbeuzeboc](https://canonical.com/blog/author/gbeuzeboc)

15 September 2026

[### Canonical is now a platinum member in the Open Source Robotics Alliance](https://canonical.com/blog/osra-membership)

Ubuntu is the home of ROS. The very first ROS distribution, Box Turtle, launched on Ubuntu 8.04 LTS, Hardy Heron, and since then, Ubuntu and ROS have grown hand in hand. With...

[Gabriel Aguiar Noury](https://canonical.com/blog/author/g-aguiar-noury)

20 August 2025

[### ROS Noetic is EOL – take action to maintain fleet security](https://canonical.com/blog/ros-noetic-is-eol-take-action-to-maintain-fleet-security)

As of May 2025, the Robot Operating System (ROS) Noetic Ninjemys officially reached its end of life (EOL). First released in 2020 as the final ROS (1) distribution, ROS Noetic...

[Florencia Cabral Berenfus](https://canonical.com/blog/author/flor-cabral)

8 August 2025

[### TurtleBot3 OpenCR firmware update from a snap](https://canonical.com/blog/turtlebot3-opencr-firmware-update-from-a-snap)

The TurtleBot3 robot is a standard platform robot in the ROS community, and it’s a reference that Canonical knows well, since we’ve used it in our tutorials. As a matter of...

[gbeuzeboc](https://canonical.com/blog/author/gbeuzeboc)

25 September 2024
