[CalendarServer-changes] [12947] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Mar 18 13:04:02 PDT 2014


Revision: 12947
          http://trac.calendarserver.org//changeset/12947
Author:   wsanchez at apple.com
Date:     2014-03-18 13:04:01 -0700 (Tue, 18 Mar 2014)
Log Message:
-----------
backup tool is long obsolete

Modified Paths:
--------------
    CalendarServer/trunk/setup.py

Removed Paths:
-------------
    CalendarServer/trunk/bin/calendarserver_backup
    CalendarServer/trunk/bin/py/calendarserver_backup
    CalendarServer/trunk/calendarserver/tools/backup.py
    CalendarServer/trunk/calendarserver/tools/backup_pg.py

Deleted: CalendarServer/trunk/bin/calendarserver_backup
===================================================================
--- CalendarServer/trunk/bin/calendarserver_backup	2014-03-18 20:01:07 UTC (rev 12946)
+++ CalendarServer/trunk/bin/calendarserver_backup	2014-03-18 20:04:01 UTC (rev 12947)
@@ -1,31 +0,0 @@
-#!/bin/sh
-# -*- sh-basic-offset: 2 -*-
-
-##
-# Copyright (c) 2014 Apple Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##
-
-set -e
-set -u
-
-wd="$(cd "$(dirname "$0")/.." && pwd)";
-
-. "${wd}/bin/_build.sh";
-
-do_setup="false";
-
-develop > /dev/null;
-
-exec "${python}" "${wd}/bin/py/$(basename "$0")" "$@";

Deleted: CalendarServer/trunk/bin/py/calendarserver_backup
===================================================================
--- CalendarServer/trunk/bin/py/calendarserver_backup	2014-03-18 20:01:07 UTC (rev 12946)
+++ CalendarServer/trunk/bin/py/calendarserver_backup	2014-03-18 20:04:01 UTC (rev 12947)
@@ -1,30 +0,0 @@
-#!/usr/bin/env python
-
-##
-# Copyright (c) 2006-2014 Apple Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##
-
-import sys
-
-#PYTHONPATH
-
-if __name__ == "__main__":
-    try:
-        sys.path.insert(0, PYTHONPATH)
-    except NameError:
-        sys.exc_clear()
-
-    from calendarserver.tools.backup import main
-    main()

Deleted: CalendarServer/trunk/calendarserver/tools/backup.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/backup.py	2014-03-18 20:01:07 UTC (rev 12946)
+++ CalendarServer/trunk/calendarserver/tools/backup.py	2014-03-18 20:04:01 UTC (rev 12947)
@@ -1,26 +0,0 @@
-#!/usr/bin/python
-
-##
-# Copyright (c) 2012-2014 Apple Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##
-
-from calendarserver.tools.backup_pg import main as main_pg
-
-#
-# FIXME: read the config plist and choose the correct backup
-# implementation based on which DB type is being used.
-# For now, hard code to Postgres.
-#
-main = main_pg

Deleted: CalendarServer/trunk/calendarserver/tools/backup_pg.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/backup_pg.py	2014-03-18 20:01:07 UTC (rev 12946)
+++ CalendarServer/trunk/calendarserver/tools/backup_pg.py	2014-03-18 20:04:01 UTC (rev 12947)
@@ -1,221 +0,0 @@
-#!/usr/bin/python
-
-##
-# Copyright (c) 2011-2014 Apple Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##
-from __future__ import print_function
-
-from getopt import getopt, GetoptError
-import os
-import subprocess
-import sys
-import tarfile
-
-from twistedcaldav.config import config
-from calendarserver.tools.util import loadConfig
-
-SIPP = "/Applications/Server.app/Contents/ServerRoot"
-if not os.path.exists(SIPP):
-    SIPP = ""
-USERNAME = "caldav"
-DATABASENAME = "caldav"
-DUMPFILENAME = "db_backup"
-
-PSQL = "%s/usr/bin/psql" % (SIPP,)
-PGDUMP = "%s/usr/bin/pg_dump" % (SIPP,)
-PGSOCKETDIR = "/var/run/caldavd/PostgresSocket"
-
-def usage(e=None):
-    name = os.path.basename(sys.argv[0])
-    print("usage: %s [options] command backup-file" % (name,))
-    print("")
-    print(" Backup or restore calendar and addressbook data")
-    print("")
-    print("options:")
-    print("  -f --config <path>: Specify caldavd.plist configuration path")
-    print("  -h --help: print this help and exit")
-    print("  -v --verbose: print additional information")
-    print("")
-    print("commands:")
-    print("  backup: create backup-file in compressed tar format (tgz)")
-    print("  restore: restore from backup-file")
-    print("")
-
-    if e:
-        sys.stderr.write("%s\n" % (e,))
-        sys.exit(64)
-    else:
-        sys.exit(0)
-
-
-
-def dumpData(dumpFile, verbose=False):
-    """
-    Use pg_dump to dump data to dumpFile
-    """
-
-    cmdArgs = [
-        PGDUMP,
-        "-h", PGSOCKETDIR,
-        "--username=%s" % (USERNAME,),
-        "--clean",
-        "--no-privileges",
-        "--file=%s" % (dumpFile,),
-        DATABASENAME
-    ]
-    try:
-        if verbose:
-            print("\nDumping data to %s" % (dumpFile,))
-            print("Executing: %s" % (" ".join(cmdArgs)))
-        out = subprocess.check_output(cmdArgs, stderr=subprocess.STDOUT)
-        if verbose:
-            print(out)
-    except subprocess.CalledProcessError, e:
-        if verbose:
-            print(e.output)
-        raise BackupError(
-            "%s failed:\n%s (exit code = %d)" %
-            (PGDUMP, e.output, e.returncode)
-        )
-
-
-
-def loadData(dumpFile, verbose=False):
-    """
-    Use psql to load data from dumpFile
-    """
-
-    cmdArgs = [
-        PSQL,
-        "-h", PGSOCKETDIR,
-        "--username=%s" % (USERNAME,),
-        "--file=%s" % (dumpFile,)
-    ]
-    try:
-        if verbose:
-            print("\nLoading data from %s" % (dumpFile,))
-            print("Executing: %s" % (" ".join(cmdArgs)))
-        out = subprocess.check_output(cmdArgs, stderr=subprocess.STDOUT)
-        if verbose:
-            print(out)
-    except subprocess.CalledProcessError, e:
-        if verbose:
-            print(e.output)
-        raise BackupError(
-            "%s failed:\n%s (exit code = %d)" %
-            (PSQL, e.output, e.returncode)
-        )
-
-
-
-class BackupError(Exception):
-    pass
-
-
-
-def error(s):
-    sys.stderr.write("%s\n" % (s,))
-    sys.exit(1)
-
-
-
-def main():
-    try:
-        (optargs, args) = getopt(
-            sys.argv[1:], "f:hv", [
-                "config=",
-                "help",
-                "verbose",
-            ],
-        )
-    except GetoptError, e:
-        usage(e)
-
-    verbose = False
-    configFileName = None
-
-    for opt, arg in optargs:
-        if opt in ("-h", "--help"):
-            usage()
-        elif opt in ("-f", "--config"):
-            configFileName = arg
-        elif opt in ("-v", "--verbose"):
-            verbose = True
-        else:
-            raise NotImplementedError(opt)
-
-    if len(args) != 2:
-        usage("Must specify a command and a backup-file name.")
-
-    command = args[0]
-    filename = args[1]
-
-    loadConfig(configFileName)
-
-    serverRoot = config.ServerRoot
-    dataRoot = config.DataRoot
-    dumpPath = os.path.join(serverRoot, DUMPFILENAME)
-
-    if command == "backup":
-
-        try:
-            dumpData(dumpPath, verbose=verbose)
-
-            if verbose:
-                print("Creating %s" % (filename,))
-            tar = tarfile.open(filename, "w:gz")
-
-            if verbose:
-                print("Adding %s" % (serverRoot,))
-            tar.add(serverRoot)
-
-            if not dataRoot.startswith(serverRoot):
-                # DataRoot is not contained within ServerRoot (i.e, it's on
-                # another volume)
-                if verbose:
-                    print("Adding %s" % (dataRoot,))
-                tar.add(dataRoot)
-
-            tar.close()
-
-            if verbose:
-                print("Done")
-        except BackupError, e:
-            error("Failed to dump database; error: %s" % (e,))
-
-    elif command == "restore":
-
-        try:
-            tar = tarfile.open(filename, "r:gz")
-
-            if verbose:
-                print("Extracting from backup file: %s" % (filename,))
-            tar.extractall(path="/")
-
-            loadData(dumpPath, verbose=verbose)
-
-            if verbose:
-                print("Cleaning up database dump file: %s" % (dumpPath,))
-            os.remove(dumpPath)
-
-        except BackupError, e:
-            error("Failed to dump database; error: %s" % (e,))
-            raise
-
-    else:
-        error("Unknown command '%s'" % (command,))
-
-if __name__ == "__main__":
-    main()

Modified: CalendarServer/trunk/setup.py
===================================================================
--- CalendarServer/trunk/setup.py	2014-03-18 20:01:07 UTC (rev 12946)
+++ CalendarServer/trunk/setup.py	2014-03-18 20:04:01 UTC (rev 12947)
@@ -237,28 +237,30 @@
         },
         scripts=[
             "bin/caldavd",
-            # "bin/calendarserver_backup",
-            "bin/calendarserver_bootstrap_database",
-            "bin/calendarserver_command_gateway",
-            "bin/calendarserver_config",
-            # "bin/calendarserver_dbinspect",
-            # "bin/calendarserver_dkimtool",
-            "bin/calendarserver_export",
-            # "bin/calendarserver_icalendar_validate",
-            # "bin/calendarserver_load_augmentdb",
-            # "bin/calendarserver_manage_postgres",
-            "bin/calendarserver_manage_principals",
-            "bin/calendarserver_manage_push",
-            "bin/calendarserver_manage_timezones",
-            "bin/calendarserver_migrate_resources",
-            # "bin/calendarserver_monitor_amp_notifications",
-            # "bin/calendarserver_monitor_notifications",
-            "bin/calendarserver_purge_attachments",
-            "bin/calendarserver_purge_events",
-            "bin/calendarserver_purge_principals",
-            "bin/calendarserver_shell",
-            "bin/calendarserver_upgrade",
-            # "bin/calendarserver_verify_data",
+            "bin/py/calendarserver_bootstrap_database",
+            # "bin/py/calendarserver_check_database_schema",
+            "bin/py/calendarserver_command_gateway",
+            "bin/py/calendarserver_config",
+            # "bin/py/calendarserver_dashboard",
+            # "bin/py/calendarserver_dbinspect",
+            # "bin/py/calendarserver_dkimtool",
+            "bin/py/calendarserver_export",
+            # "bin/py/calendarserver_icalendar_validate",
+            # "bin/py/calendarserver_load_augmentdb",
+            # "bin/py/calendarserver_manage_postgres",
+            "bin/py/calendarserver_manage_principals",
+            "bin/py/calendarserver_manage_push",
+            "bin/py/calendarserver_manage_timezones",
+            "bin/py/calendarserver_migrate_resources",
+            # "bin/py/calendarserver_monitor_amp_notifications",
+            # "bin/py/calendarserver_monitor_notifications",
+            # "bin/py/calendarserver_monitor_work",
+            "bin/py/calendarserver_purge_attachments",
+            "bin/py/calendarserver_purge_events",
+            "bin/py/calendarserver_purge_principals",
+            "bin/py/calendarserver_shell",
+            "bin/py/calendarserver_upgrade",
+            # "bin/py/calendarserver_verify_data",
         ],
         data_files=[
             ("caldavd", ["conf/caldavd.plist"]),
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140318/92b3aeb5/attachment-0001.html>


More information about the calendarserver-changes mailing list