On Mon, Aug 21, 2017 at 11:03 PM, Erdloch <erdl...@gmail.com> wrote:
> I am currently running Trac. 1.2. and I tried to run the TracHotBackupScript
> from trac-hacks.org on Ubuntu 16.04 using the following command, but I get
> these errors:
>
> root@trac:/home/trac/Downloads# ./trac-hot-backup.py /var/lib/trac/test
> /home/trac/Downloads/testbackup
>
> Beginning hot backup of '/var/lib/trac/test'.
> Backing up project to
> '/home/trac/Downloads/testbackup/test-2017-08-21-1548'...
> Traceback (most recent call last):
>   File "./trac-hot-backup.py", line 161, in <module>
>     backup_subdir])
>   File "/usr/lib/python2.7/subprocess.py", line 523, in call
>     return Popen(*popenargs, **kwargs).wait()
>   File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
>     errread, errwrite)
>   File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
>     raise child_exception
> OSError: [Errno 2] No such file or directory

Path of trac-admin is hard-coded in trac-hot-backup.py at line 40.
https://trac-hacks.org/browser/trachotbackupscript/anyrelease/trac-hot-backup.py#L40.

You should revise the path before using it.

However, it could be able to use without changes using python -m
trac.admin.console rather than hard-coded trac-admin like this:

diff --git a/trachotbackupscript/anyrelease/trac-hot-backup.py
b/trachotbackupscript/anyrelease/trac-hot-backup.py
index fe04787a6..5975abd23 100755
--- a/trachotbackupscript/anyrelease/trac-hot-backup.py
diff --git a/trachotbackupscript/anyrelease/trac-hot-backup.py
b/trachotbackupscript/anyrelease/trac-hot-backup.py
index fe04787a6..a0e59a107 100755
--- a/trachotbackupscript/anyrelease/trac-hot-backup.py
+++ b/trachotbackupscript/anyrelease/trac-hot-backup.py
@@ -36,9 +36,6 @@ import time

 # Global Settings

-# Path to trac-admin utility
-tracadmin = r'usr/bin/trac-admin'
-
 # Default number of backups to keep around (0 for "keep them all")
 num_backups = int(os.environ.get('TRAC_HOTBACKUP_BACKUPS_NUMBER', 64))

@@ -150,6 +147,12 @@ if __name__ == '__main__':
             usage(sys.stderr)
             sys.exit(2)

+    try:
+        import trac.admin.console
+    except ImportError:
+        print >> sys.stderr, "You need to install Trac to use this script."
+        sys.exit(2)
+
     print "Beginning hot backup of '"+ project_dir + "'."

     # Step 1: Ask trac-admin to make a hot copy of a project.
@@ -157,8 +160,8 @@ if __name__ == '__main__':
     backup_subdir = os.path.join(backup_dir,
                                  project + "-" +
time.strftime(r"%Y-%m-%d-%H%M"))
     print "Backing up project to '" + backup_subdir + "'..."
-    err_code = subprocess.call([tracadmin, project_dir, "hotcopy",
-                                backup_subdir])
+    err_code = subprocess.call([sys.executable, '-m', 'trac.admin.console',
+                                project_dir, "hotcopy", backup_subdir])
     if err_code != 0:
         print >> sys.stderr, "Unable to backup the repository."
         sys.exit(err_code)

-- 
Jun Omae <jun6...@gmail.com> (大前 潤)

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-users+unsubscr...@googlegroups.com.
To post to this group, send email to trac-users@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to