code: def capture_heroku_database(self):
          
          self.print_message("Capturing database backup for app '%s'" % self.args.source_app)
          args = [
              "heroku",
              "pg:backups:capture",
              "--app=%s" % self.args.source_app,
          ]
          if self.args.use_pgbackups:
              args = [
                  "heroku",
                  "pgbackups:capture",
                  "--app=%s" % self.args.source_app,
                  "--expire",
              ]
          subprocess.check_call(args)
docs: Capture Heroku database backup.