Kopia's output is hostile to sending via e-mail

I am trying to have the output of kopia repo sync-to S3 sent to me via mail, but the output is inherently hostile against e-mail, since it contains lots of control characters, which mail(x) has trouble getting into the body. So it just creates an application/octet-stream attachment.

Anyone having a solution for that? I tried some sed/tr but I cannot get finally rid of these pesky ^M which mark linebreaks.

Try --disable-color.

I did, but that didn’t help. I captured Kopia’s output using &> sync.txt:

[root@kopia repos]# cat sync.txt -vet
Synchronizing repositories:^[[0m$
  Source:      Filesystem: /mnt/kopia/ST7A^[[0m$
  Destination: S3: s3.eu-central-1.wasabisys.com kopiast7a^[[0m$
^[[32mNOTE: By default no BLOBs are deleted, pass --delete to allow it.^[[0m$
Looking for BLOBs to synchronize...^[[0m$
^M  Found 1 BLOBs in the destination repository (2.4 KB)^M  Found 2001 BLOBs in the destination repository (45 GB)  ^M  Found 5001 BLOBs in the destination repository (114.4 GB)^M  Found 7001 BLOBs in the destination repository (160.6 GB)^M  Found 8001 BLOBs in the destination repository (183.6 GB)^M  Found 10001 BLOBs in the destination repository (229.8 GB)^M  Found 12001 BLOBs in the destination repository (276.1 GB)^M  Found 15001 BLOBs in the destination repository (345.4 GB)^M  Found 18001 BLOBs in the destination repository (415 GB)  ^M  Found 20001 BLOBs in the destination repository (461 GB)  ^M  Found 22001 BLOBs in the destination repository (507.2 GB)^M  Found 24001 BLOBs in the destination repository (553.6 GB)^M  Found 25164 BLOBs in the destination repository (579.9 GB)$
^M  Found 1 BLOBs (2.4 KB) in the source repository, 0 (0 B) to copy^M  Found 9586 BLOBs (221.3 GB) in the source repository, 0 (0 B) to copy^M  Found 20266 BLOBs (468.8 GB) in the source repository, 0 (0 B) to copy^M  Found 25060 BLOBs (579.4 GB) in the source repository, 0 (0 B) to copy$
  Found 0 BLOBs to delete (0 B), 25060 in sync (579.4 GB)^[[0m$

Tried that just now, WorkedForMe ™

Looks like some command outputs are still colorized, let me fix that…

Fix submitted. Should be in the new build shortly.

1 Like

Thanks - got it with the latest nightly. I am using it now like this

0 3 * * * * root cd / && run-parts /etc/cron.kopia | sed -e "s/\r/\n/g" | mail -s "<your subject here>" <email@recipient.dom>

Just in case anyone wonders about how to get rid of those CTRL-M special chars.

Yeah, the Ctrl-M is easy to remove but why doesn’t kopia just omit it?

I thought this was addressed, is there any remaining case where color ansi codes are emitted? Try --disable-color.

It has been solved for me back then - no issues with that anymore! I guess the comment was not about the solution, but as of why kopia is throwing a Crtrl-M in there in the first place.

To test it I ran

kopia snapshot create --disable-color /data/archive > ~/kopia.log 2>&1

and the output contains many lines like this

 ^M | 0 hashing, 0 hashed (0 B), 1 cached (18 MB), uploaded 0 B, estimating...