6.22. foundations.rotatingBackup

rotatingbackup.py

Platform:
Windows, Linux, Mac Os X.
Description:
Defines the RotatingBackup class.
Others:
Code extracted from rotatingbackup.py written by leo.ss.pku@gmail.com

6.22.1. Module Attributes

foundations.rotatingBackup.LOGGER

6.22.2. Classes

class foundations.rotatingBackup.RotatingBackup(source=None, destination=None, count=3)[source]

Bases: object

Defines a rotating backup system.

Initializes the class.

Warning

Backups destination folder should not be the same than the folder containing the source to be backuped!

Usage:

>>> file = "File.txt"
>>> destination = "backup"
>>> backup = RotatingBackup(file, destination)
>>> backup.backup()
True
>>> for i in range(3):
...     backup.backup()
...
True
True
True
>>> import os
>>> os.listdir(destination)
['File.txt', 'File.txt.1', 'File.txt.2', 'File.txt.3']
Parameters:
  • source (unicode) – Backup source.
  • destination (unicode) – Backup destination.
  • count (int) – Backups count.
source[source]

Property for self.__source attribute.

Returns:self.__source.
Return type:unicode
destination[source]

Property for self.__destination attribute.

Returns:self.__destination.
Return type:unicode
count[source]

Property for self.__count attribute.

Returns:self.__count.
Return type:int
backup()[source]

Does the rotating backup.

Returns:Method success.
Return type:bool