# StopNow(), Backup and cancellation tokens

**URL:** https://forum.duplicati.com/t/stopnow-backup-and-cancellation-tokens/16223
**Category:** Developer
**Created:** [May 4, 2023, 11:28am UTC](https://forum.duplicati.com/t/stopnow-backup-and-cancellation-tokens/16223 "2023-05-04T11:28:14Z")
**Posts on this page:** 1
**Showing post:** 15

<div class="post-metadata">

### Author: ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)
#### Post date: [May 5, 2023, 10:25pm UTC](https://forum.duplicati.com/t/stopnow-backup-and-cancellation-tokens/16223/15 "2023-05-05T22:25:54Z")

</div>

> [@mr-russ](#):
>
> Separate docs are great but hard to ensure it’s maintained.

Agree that a separate docs can be hard. I’d like to see a small comment block at the top of each file.  
Giant comment block in one place might go as neglected as a separate doc. Lines all over are hard.

Because the overall architecture is pretty sprawling, and subject to slow change, a design summary possibly is a reasonable separate document, then code comments spread around could add details.

Pretty pictures are nice, but lead to potential difficulty and friction if somebody ever has to change it.

Regardless of form, my goal is to be able to understand the design so we know its problems (or not), giving us some idea of what to change (or maybe dare not change) to accomplish what the goals are.

I wasn’t sure where some of your database comments were heading. SQLite is missing big-database capabilities, but we’re not taking advantage of everything it has yet, as we try to get to stable and fast.

> [@mr-russ](#):
>
> So a documented design for data flow in backuphandler would assist with that.

Agree completely. I wish we had that. Unless we get some aid, is this something you’d like to work on?  
The forum post I wrote is a very high level view, but I’d like to get down a little further to database work.

Regarding Control-C, I was doing automated interrupt testing before using random kill, maybe a repair.

```plaintext
        timeout = random.randint(1, 30)
        count_started += 1
        print('Running backup at', datetime.datetime.now())
        result = subprocess.run(args, timeout=timeout, capture_output=True)
        exit_code = result.returncode
        print('Exit code', exit_code)
        if exit_code >= 100:
            print('stderr was:')
            error = result.stderr.decode()
            print(error)
            if re.search('ErrorID: MissingRemoteFiles', error):
                count_missing += 1
                repair()
            elif re.search('ErrorID: ExtraRemoteFiles', error):
                count_extra += 1
                repair()
            elif re.search('Unexpected number of remote volumes marked as deleted', error):
                count_marked_deleted += 1
 # repair()
 # pass
                break
            else:
                count_unknown += 1
                break

```

which, from where the code landed when I gave up, looks like it was probably two that repair could fix (and I think they have Issues filed), maybe one that it couldn’t, and then some unclassified type of fail.

Some sample statistics from that random kill test script (plus related commentary) can be found [here](https://forum.duplicati.com/t/no-more-backup-because-of-one-missing-file/14403/3).

What kind are you getting? I really dislike the ones that can’t be rescued regardless of extreme efforts.

---

_[View the full topic](https://forum.duplicati.com/t/stopnow-backup-and-cancellation-tokens/16223)._
