TracFaq update - attachments are missing

39 views
Skip to first unread message

Michela Ledwidge

unread,
Feb 12, 2016, 11:06:15 AM2/12/16
to Trac Users
For the benefits of anyone else upgrade old tracs, suggest adding something like this to TracFaq. It quite took a while to troubleshoot upgrading from 0.12.2 to 1.1.6.

Is there no way to determine an attachment's path?

--

Q: Attachments are missing after upgrade


Attachments from earlier versions of trac cannot simply be copied into the new file structure as the path and filename are now generated. The trac upgrade scripts rely on the existence of the old /path/to/projenv/attachments folder and will attempt to delete it when the upgrade is complete. If the legacy attachments folder is not found at upgrade time, restore it and then run the db28.py script above to migrate legacy files

To find the path to a file, <INSERT>

--

Michela

RjOllos

unread,
Feb 12, 2016, 11:48:18 AM2/12/16
to Trac Users
There is an entry addressing the same issue,

Did you see that entry?

The attachments should be moved when running trac-admin upgrade, but there is a defect preventing that and we haven't determined the cause yet.

- Ryan 

Atilio Medina

unread,
Feb 8, 2017, 12:12:16 PM2/8/17
to Trac Users
Hi Ryan,

We have done an upgrade by manually exporting the old sqlite database into the new mysql database. The uploads on the old system provided the full path. The new uploads seem to create some kind of hash to create the directory and file name. Is there a way to update either the file locations or the references on the database? The attachment table doesn't seem to have any references to this new paths. Not sure how it's implemented.

Any help is appreciated.

Thanks,
Atilio

Ryan Ollos

unread,
Feb 8, 2017, 12:18:19 PM2/8/17
to trac-...@googlegroups.com
On Wed, Feb 8, 2017 at 9:12 AM Atilio Medina <atilio...@utah.gov> wrote:
Hi Ryan,

We have done an upgrade by manually exporting the old sqlite database into the new mysql database. The uploads on the old system provided the full path.

Using the TracMigratePlugin would have been good:
 
The new uploads seem to create some kind of hash to create the directory and file name. Is there a way to update either the file locations or the references on the database? The attachment table doesn't seem to have any references to this new paths. Not sure how it's implemented.

You didn't mention which Trac version you were upgrade from and to. I'll assume you moved from Trac < 1.0 to Trac >= 1.0. Running "trac-admin $env upgrade" should have migrated the attachments.

The db28.py upgrade script creates hashes for the attachments. You can invoke it manually as described in the FAQ:

- Ryan

Atilio Medina

unread,
Feb 8, 2017, 12:25:02 PM2/8/17
to Trac Users
It was more like a new install and converting and exporting the database manually.  We didn't use the migrate plugin. The old was 0.12 and the new is 1.12. 

Old

New

Where is this db28.py file located? I don't seem to see it on either server. Do have have to have the old and new environments on the same server in order to run db28.py ?

Thanks,
Atilio


On Friday, February 12, 2016 at 9:06:15 AM UTC-7, Michela Ledwidge wrote:

Atilio Medina

unread,
Feb 8, 2017, 12:25:54 PM2/8/17
to Trac Users


On Wednesday, February 8, 2017 at 10:25:02 AM UTC-7, Atilio Medina wrote:
It was more like a new install and converting and exporting the database manually.  We didn't use the migrate plugin. The old was 0.12 and the new is 1.12. 

Old

New

Where is this db28.py file located? I don't seem to see it on either server. Do we have to have the old and new environments on the same server in order to run db28.py ?

Ryan Ollos

unread,
Feb 8, 2017, 12:39:17 PM2/8/17
to trac-...@googlegroups.com
On Wed, Feb 8, 2017 at 9:25 AM Atilio Medina <atilio...@utah.gov> wrote:


On Wednesday, February 8, 2017 at 10:25:02 AM UTC-7, Atilio Medina wrote:
It was more like a new install and converting and exporting the database manually.  We didn't use the migrate plugin. The old was 0.12 and the new is 1.12.
 
Where is this db28.py file located? I don't seem to see it on either server. Do we have to have the old and new environments on the same server in order to run db28.py ?

Thanks,
Atilio

You only need the new environment to run db28.py, in fact it will be executed when upgrading from Trac 0.12 when running trac-admin $env upgrade. Have you read TracUpgrade?

Did you skip all of the upgrade steps by manually changing the  "database_version" value in the "system" table? Or did you run trac-admin $env upgrade and the attachments just failed to migrate?

db28.py is part of the Trac distribution. It will be packaged in the .egg or .whl of your install. However, the FAQ shows how you can invoke the upgrade step from a script. I'd only recommend doing that if you've run the environment upgrade and the attachments have failed due to the unknown defect described in the FAQ and #11370.

If you manually changed "database_version" in the "system" table when moving from SQLite to MySQL, I suggest you revert the value to "26", which is the value from Trac 0.12.x, and execute "trac-admin $env upgrade".


Well, you are where you are now, but it would have been much better to use TracMigratePlugin and follow the steps in TracUpgrade. See also:

- Ryan

Atilio Medina

unread,
Feb 8, 2017, 4:43:19 PM2/8/17
to Trac Users
I've cloned the old system and run the upgrade steps on it. The attachments paths have been updated correctly. I tried the migration from sqlite to mysql using 


and I am getting the following, any ideas?

trac-migrate.py --in-place /var/trac/projects/main mysql://user:password@localhost:3306/trac
Traceback (most recent call last):
  File "./trac-migrate.py", line 55, in <module>
    sys.exit(main(sys.argv[1:]) or 0)
  File "./trac-migrate.py", line 51, in main
    return TracMigrationCommand(env)._do_migrate(dest, dburi)
  File "/var/trac-migrate/tracmigrate/admin.py", line 55, in _do_migrate
    return self._do_migrate_inplace(dburi)
  File "/var/trac-migrate/tracmigrate/admin.py", line 86, in _do_migrate_inplace
    dst_env = self._create_env(env_path, dburi)
  File "/var/trac-migrate/tracmigrate/admin.py", line 128, in _create_env
    env = MigrateEnvironment(env_path, create=True, options=options)
  File "/python27/lib/python2.7/site-packages/Trac-1.2-py2.7.egg/trac/core.py", line 128, in __call__
    self.__init__(*args, **kwargs)
  File "/python27/lib/python2.7/site-packages/Trac-1.2-py2.7.egg/trac/env.py", line 299, in __init__
    self.create(options)
  File "/python27/lib/python2.7/site-packages/Trac-1.2-py2.7.egg/trac/env.py", line 591, in create
    DatabaseManager(self).init_db()
  File "/python27/lib/python2.7/site-packages/Trac-1.2-py2.7.egg/trac/db/api.py", line 337, in init_db
    connector, args = self.get_connector()
  File "/python27/lib/python2.7/site-packages/Trac-1.2-py2.7.egg/trac/db/api.py", line 606, in get_connector
    scheme=scheme))
trac.core.TracError: Unsupported database type "mysql"


On Friday, February 12, 2016 at 9:06:15 AM UTC-7, Michela Ledwidge wrote:

RjOllos

unread,
Feb 8, 2017, 5:06:29 PM2/8/17
to Trac Users
Do you have MySQL-python installed?

- Ryan 

Atilio Medina

unread,
Feb 8, 2017, 5:20:29 PM2/8/17
to Trac Users
Thanks Ryan, that seemed to have been the issue. It worked now.


trac-migrate.py --in-place /var/trac/projects/main mysql://user:pass@localhost:3306/trac
Copying tables:
  attachment table... 161 records.
  auth_cookie table... 25 records.
  cache table... 1 records.
  component table... 11 records.
  enum table... 26 records.
  milestone table... 15 records.
  node_change table... 426063 records.
  notify_subscription table... 0 records.
  notify_watch table... 0 records.
  permission table... 35 records.
  report table... 14 records.
  repository table... 3 records.
  revision table... 13043 records.
  session table... 61467 records.
  session_attribute table... 134962 records.
  system table... 1 records.
  ticket table... 354 records.
  ticket_change table... 4109 records.
  ticket_custom table... 0 records.
  version table... 10 records.
  wiki table... 1221 records.
Back up conf/trac.ini to conf/trac.ini.migrate-1486592320 in /var/trac/projects/main.


On Friday, February 12, 2016 at 9:06:15 AM UTC-7, Michela Ledwidge wrote:
Reply all
Reply to author
Forward
0 new messages