From aaf6e899f28ecfc5d75bc378a7dc6ccee5b2249e Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Wed, 8 May 2013 19:32:26 -0400 Subject: Added support for backup/restore on upgrade. The upgrade framework has been modified to support backup and restore functionality. A new method backup(filename) has been added to save a file into a backup folder. The CLI's have been modified to accept a --revert parameter which will restore the backup files one version at a time. Ticket #583 --- base/common/python/pki/util.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 base/common/python/pki/util.py (limited to 'base/common/python/pki/util.py') diff --git a/base/common/python/pki/util.py b/base/common/python/pki/util.py new file mode 100644 index 000000000..7db4fbe79 --- /dev/null +++ b/base/common/python/pki/util.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +# Authors: +# Endi S. Dewata +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2013 Red Hat, Inc. +# All rights reserved. +# + +import os +import shutil + + +def copyfile(source, dest): + + dir = os.path.dirname(dest) + if not os.path.exists(dir): + os.makedirs(dir) + + shutil.copy2(source, dest) + st = os.stat(source) + os.chown(dest, st.st_uid, st.st_gid) -- cgit