code: def save(self, filename=None):
          
          if filename:
              if ".db" in filename:
                  filename = filename.split(".")[0]
              self.properties.db_name = filename
          else:
              self.properties.db_name = "{}".format(self.properties.name)
  
          # Does file exist? If so, append data
          if os.path.isfile("{}.db".format(self.properties.db_name)):
              his = self._read_from_sql(
                  'select * from "{}"'.format("history"), self.properties.db_name
              )
              his.index = his["index"].apply(Timestamp)
              try:
                  last = his.index[-1]
                  df_to_backup = self.backup_histories_df()[last:]
              except IndexError:
                  df_to_backup = self.backup_histories_df()
  
          else:
              self._log.debug("Creating a new backup database")
              df_to_backup = self.backup_histories_df()
  
          # DataFrames that will be saved to SQL
          with contextlib.closing(
              sqlite3.connect("{}.db".format(self.properties.db_name))
          ) as con:
              sql.to_sql(
                  df_to_backup,
                  name="history",
                  con=con,
                  index_label="index",
                  index=True,
                  if_exists="append",
              )
  
          # Saving other properties to a pickle file...
          prop_backup = {}
          prop_backup["device"] = self.dev_properties_df()
          prop_backup["points"] = self.points_properties_df()
          with open("{}.bin".format(self.properties.db_name), "wb") as file:
              pickle.dump(prop_backup, file)
  
          self._log.info("Device saved to {}.db".format(self.properties.db_name))
docs: Save the point histories to sqlite3 database.  
          Save the device object properties to a pickle file so the device can be reloaded.