| Home | Trees | Indices | Help |
|
|---|
|
|
1 # -*- coding: iso-8859-1 -*-
2 # vim: set ft=python ts=3 sw=3 expandtab:
3 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
4 #
5 # C E D A R
6 # S O L U T I O N S "Software done right."
7 # S O F T W A R E
8 #
9 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
10 #
11 # Copyright (c) 2004-2007,2010 Kenneth J. Pronovici.
12 # All rights reserved.
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License,
16 # Version 2, as published by the Free Software Foundation.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 #
22 # Copies of the GNU General Public License are available from
23 # the Free Software Foundation website, http://www.gnu.org/.
24 #
25 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
26 #
27 # Author : Kenneth J. Pronovici <pronovic@ieee.org>
28 # Language : Python 2 (>= 2.7)
29 # Project : Cedar Backup, release 2
30 # Purpose : Implements the standard 'purge' action.
31 #
32 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
33
34 ########################################################################
35 # Module documentation
36 ########################################################################
37
38 """
39 Implements the standard 'purge' action.
40 @sort: executePurge
41 @author: Kenneth J. Pronovici <pronovic@ieee.org>
42 """
43
44
45 ########################################################################
46 # Imported modules
47 ########################################################################
48
49 # System modules
50 import logging
51
52 # Cedar Backup modules
53 from CedarBackup2.filesystem import PurgeItemList
54
55
56 ########################################################################
57 # Module-wide constants and variables
58 ########################################################################
59
60 logger = logging.getLogger("CedarBackup2.log.actions.purge")
61
62
63 ########################################################################
64 # Public functions
65 ########################################################################
66
67 ##########################
68 # executePurge() function
69 ##########################
70
72 """
73 Executes the purge backup action.
74
75 For each configured directory, we create a purge item list, remove from the
76 list anything that's younger than the configured retain days value, and then
77 purge from the filesystem what's left.
78
79 @param configPath: Path to configuration file on disk.
80 @type configPath: String representing a path on disk.
81
82 @param options: Program command-line options.
83 @type options: Options object.
84
85 @param config: Program configuration.
86 @type config: Config object.
87
88 @raise ValueError: Under many generic error conditions
89 """
90 logger.debug("Executing the 'purge' action.")
91 if config.options is None or config.purge is None:
92 raise ValueError("Purge configuration is not properly filled in.")
93 if config.purge.purgeDirs is not None:
94 for purgeDir in config.purge.purgeDirs:
95 purgeList = PurgeItemList()
96 purgeList.addDirContents(purgeDir.absolutePath) # add everything within directory
97 purgeList.removeYoungFiles(purgeDir.retainDays) # remove young files *from the list* so they won't be purged
98 purgeList.purgeItems() # remove remaining items from the filesystem
99 logger.info("Executed the 'purge' action successfully.")
100
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 | http://epydoc.sourceforge.net |