lib.backup
This library creates a zip file with the configuration of SmartHomeNG.
- lib.backup.backup_directory(backupzip, source_dir, extension='.yaml', dest_dir=None)[Quellcode]
Backup all files with a certain extension from the given directory to a zip-archive
- Parameter:
backupzip – Name of the zip-archive (full pathname)
source_dir – Directory where the yaml-files to backup are located
extension – Extension of the files to backup (default is .yaml)
- lib.backup.backup_directory2(backupzip, source_dir, extension='.yaml', dest_dir=None)[Quellcode]
Backup all files with a certain extension from the given directory to a zip-archive
- Parameter:
backupzip – Name of the zip-archive (full pathname)
source_dir – Directory where the yaml-files to backup are located
extension – Extension of the files to backup (default is .yaml)
- lib.backup.backup_etc_directory(etc_dir, backupzip)[Quellcode]
Backup selective files from ../etc directory to zip file
A list of yaml files and certificate files are backed up
- Parameter:
etc_dir – path to source directory: ../etc directory
backupzip – ZIP file to back up to
- lib.backup.backup_file(backupzip, source_dir, arc_dir, filename)[Quellcode]
Backup one file to a zip-archive
- Parameter:
backupzip – Name of the zip-archive (full pathname)
source_dir – Directory where the file to backup is located
arc_dir – Name of destination directory in the zip-archive
filename – Name of the file to backup
- lib.backup.create_backup(conf_base_dir, base_dir, filename_with_timestamp=False, before_restore=False, config_etc=False)[Quellcode]
Create a zip file containing the configuration of SmartHomeNG. The zip file is stored in var/backup
This function can be called without an existing sh object (backup via commandline option), so it may nor use any references via ‚sh.‘
- Parameter:
conf_base_dir – basedir for configuration (should be ‚extern_conf_dir‘ to reflect –config_dir option)
base_dir – var-directory. If empty or ommited, conf_base_dir/var is used.
config_etc – True if –config_etc was given on the command line; otherwise the config_etc setting of etc/smarthome.yaml decides where the user config lives
- Rückgabe:
- lib.backup.get_backupdate()[Quellcode]
- lib.backup.get_backuptime()[Quellcode]
- lib.backup.get_lastbackuptime()[Quellcode]
This method reads the file ‚last_backup‘ and returns the timestamp.
- Rückgabe:
last backup time
- Rückgabetyp:
str
- lib.backup.make_backup_directories(base_dir)[Quellcode]
Create the backup-dirctory and the restore-directory, if the do not already exist
- Parameter:
base_dir
- Rückgabe:
- lib.backup.restore_backup(conf_base_dir, base_dir, config_etc=False)[Quellcode]
Restore configuration from a zip-archive to the SmartHomeNG instance.
The zip-archive is read from var/restore. It has to be the only file in that directory
This function can be called without an existing sh object (backup via commandline option), so it may nor use any references via ‚sh.‘
- Parameter:
conf_base_dir – basedir for configuration (should be ‚extern_conf_dir‘ to reflect –config_dir option)
base_dir – var-directory. If empty or ommited, conf_base_dir/var is used.
config_etc – True if –config_etc was given on the command line; otherwise the config_etc setting of etc/smarthome.yaml decides where the user config lives
- Rückgabe:
- lib.backup.restore_directory(restorezip, arc_dir, dest_dir, overwrite=False)[Quellcode]
Restore all files from a certain archive directory to a given destination directory
- Parameter:
restorezip – Name of the zip-archive (full pathname)
arc_dir – Name of source directory in the zip-archive
dest_dir – Destinaion directory where the file should be restored to
overwrite – Overwrite file in destination, if it already exists
- lib.backup.restore_directory2(restorezip, arc_dir, dest_dir, overwrite=False)[Quellcode]
Restore all files from a certain archive directory to a given destination directory
- Parameter:
restorezip – Name of the zip-archive (full pathname)
arc_dir – Name of source directory in the zip-archive
dest_dir – Destinaion directory where the file should be restored to
overwrite – Overwrite file in destination, if it already exists
- lib.backup.restore_file(restorezip, arc_dir, filename, dest_dir, overwrite=False)[Quellcode]
- Parameter:
restorezip – Name of the zip-archive (full pathname)
arc_dir – Name of source directory in the zip-archive
filename – Name of the file to restore
dest_dir – Destinaion directory where the file should be restored to
overwrite – Overwrite file in destination, if it already exists
- Rückgabe:
- lib.backup.write_lastbackuptime(timestamp, timefile)[Quellcode]
This method writes the PID to the pidfile and locks it while the process is running.
- Parameter:
pid (int) – PID of SmartHomeNG
pidfile (str) – Name of the pidfile to write to