| 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 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.3)
29 # Project : Cedar Backup, release 2
30 # Revision : $Id: purge.py 741 2007-03-25 16:18:22Z pronovic $
31 # Purpose : Implements the standard 'purge' action.
32 #
33 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
34
35 ########################################################################
36 # Module documentation
37 ########################################################################
38
39 """
40 Implements the standard 'purge' action.
41 @sort: executePurge
42 @author: Kenneth J. Pronovici <pronovic@ieee.org>
43 """
44
45
46 ########################################################################
47 # Imported modules
48 ########################################################################
49
50 # System modules
51 import logging
52
53 # Cedar Backup modules
54 from CedarBackup2.filesystem import PurgeItemList
55
56
57 ########################################################################
58 # Module-wide constants and variables
59 ########################################################################
60
61 logger = logging.getLogger("CedarBackup2.log.actions.purge")
62
63
64 ########################################################################
65 # Public functions
66 ########################################################################
67
68 ##########################
69 # executePurge() function
70 ##########################
71
73 """
74 Executes the purge backup action.
75
76 For each configured directory, we create a purge item list, remove from the
77 list anything that's younger than the configured retain days value, and then
78 purge from the filesystem what's left.
79
80 @param configPath: Path to configuration file on disk.
81 @type configPath: String representing a path on disk.
82
83 @param options: Program command-line options.
84 @type options: Options object.
85
86 @param config: Program configuration.
87 @type config: Config object.
88
89 @raise ValueError: Under many generic error conditions
90 """
91 logger.debug("Executing the 'purge' action.")
92 if config.options is None or config.purge is None:
93 raise ValueError("Purge configuration is not properly filled in.")
94 if config.purge.purgeDirs is not None:
95 for purgeDir in config.purge.purgeDirs:
96 purgeList = PurgeItemList()
97 purgeList.addDirContents(purgeDir.absolutePath) # add everything within directory
98 purgeList.removeYoungFiles(purgeDir.retainDays) # remove young files *from the list* so they won't be purged
99 purgeList.purgeItems() # remove remaining items from the filesystem
100 logger.info("Executed the 'purge' action successfully.")
101
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Jan 10 18:01:40 2010 | http://epydoc.sourceforge.net |