code: def dump_database(id):
      
      log("Generating a backup of the database on Heroku...")
  
      dump_filename = "data.dump"
      data_directory = "data"
      dump_dir = os.path.join(data_directory, id)
      if not os.path.exists(dump_dir):
          os.makedirs(dump_dir)
  
      subprocess.call("heroku pg:backups capture --app " + id, shell=True)
  
      backup_url = subprocess.check_output(
          "heroku pg:backups public-url --app " + id, shell=True)
      backup_url = backup_url.replace('"', '').rstrip()
      backup_url = re.search("https:.*", backup_url).group(0)
      print(backup_url)
  
      log("Downloading the backup...")
      dump_path = os.path.join(dump_dir, dump_filename)
      with open(dump_path, 'wb') as file:
          subprocess.call(['curl', '-o', dump_path, backup_url], stdout=file)
  
      return dump_path
docs: Backup the Postgres database locally.