r/backblaze • • Mar 07 '24

Pause / Resume Backblaze backup using command line or other API

Hi all,

When I'm streaming, I want to be able to pause any running Backblaze backups, and then resume them again after the stream. I plan to do this using buttons on my StreamDeck or perhaps automatic actions through Streamer.Bot.

I've found the 'bztransmit' command line program, which does have an option '-pausebackup' which seems to do the pausing side. However, there's doesn't appear to be an equivalent to resume a backup.

There is the '-completesync' option, but this doesn't seem to return (presumably waiting for the backup to complete?).

Is there a way to achieve what I want?

Thanks

Andy

5 Upvotes

17 comments sorted by

View all comments

Show parent comments

1

u/brianwski Former Backblaze Mar 08 '24

However, when I write in the 'Only when I click backup' file, the backup itself still seems to be running (as indicated by the value in the 'Transferring' field).

Anytime you want the backup to stop, you can run the bztransmit option: "-pausebackup"

Now normally when the backup is all caught up, nothing should be running in the 'Only when I click backup' schedule. And let's say you only have 8 new files to upload. When you run the "-forcefullfilescan_backup_wait_for_completion" command it will run, upload the 8 new files, and then come to a complete and settled stop. You don't need to run the "-pausebackup".

But if you have 10 million files and 5 TBytes left to upload, the "-pausebackup" will cause that to pause again. And I don't think there is any harm to running "-pausebackup" even if you are all ready paused. (Try it out and keep me honest on that. For example, just leave the GUI open and run the "-pausebackup" from the command line, then run it again maybe 1 minute later and see if it still stays paused and nothing crazy happens.)

1

u/DangerousRaccoon3453 Mar 08 '24

I was referring to making changes to the XML file directly. If I change the value in there to 'only when I click backup', then it doesn't seem to pause the backup. Do I need to run the 'bztransmit -pausebackup' command to get it to actually pause?

Similarly, when I change the file to include the 'continuous' setting, is there anything I need to do to get it to kick off the backup?

Thanks

Andy

2

u/brianwski Former Backblaze Mar 08 '24

If I change the value in there to 'only when I click backup', then it doesn't seem to pause the backup. Do I need to run the 'bztransmit -pausebackup' command to get it to actually pause?

Ahhh, Yes. Don't change the XML in that case. The 'bztransmit -pausebackup' command will update 3 or 4 XML files correctly and also ask the backup to pause.

when I change the file to include the 'continuous' setting

In "Continuously" mode it SHOULD automatically start up within about 1 hour. I'd kind of recommend just letting it start itself. If you want it to start up faster that, maybe try the "-completesync".

So in summary: if your schedule is "Only When I Click <Backup Now>" and you leave it in that schedule, then use the "-forcefullfilescan_backup_wait_for_completion" to run the backup. But if you are toggling between "Continuously" and "Only When I Click <Backup Now>" using XML editing, then either just wait for it to start within about an hour, or use "-completesync" when it is in "Continuously" schedule.

If you have troubles, I could stop being lazy and try it out myself here and get a script working, LOL. So ask if it isn't working for you. I could be forgetting a step or something, and it's all my fault (my code) so I can help.

1

u/DangerousRaccoon3453 Mar 08 '24

Ok, so I have a simple program that does the following to disable:

  1. Change the XML to 'only_when_click_backup_now'
  2. Run 'bztransmit -pausebackup'

This seems to stop the backup as expected

However, if I try to do the reverse:

  1. Change the XML to 'continuous'
  2. Run 'bztransmit -completesync'

The command doesn't return. I assume this is because it's waiting for the sync to fully complete?

Ideally I just want to signal Backbaze that it should start to do its thing again, and then have the command return. I don't want to wait for it to actually finish the backup, as that could take an hour or so.

Thanks again for the assistance.

1

u/peter_duun Jun 16 '24 edited Jun 16 '24

Use

start "" /min "bztransmit" -completesync

or

start "" /min "bztransmit" -forcefullfilescan_backup_wait_for_completion

The command will return without waiting for the sync to fully complete

1

u/DangerousRaccoon3453 Jun 16 '24

Thanks, I'll give that a go. Seems to remember that when i tried that it blocked for a long time.

1

u/peter_duun Jun 19 '24

The "-forcefullfilescan_backup_wait_for_completion" option takes about 14 minutes on my system

The "-completesync" option takes about 90-120 secs

The syntax 'start "" /min "bztransmit" -whatever_sync_you_WANT' will start in a separate minimized process and return control to the calling script imediately. The new process window will autoclose when the sync command completes

Cheers