Edgewall Software
Modify

Opened 15 years ago

Closed 14 years ago

#8954 closed enhancement (fixed)

[PATCH] trac-admin hotcopy should export database dump for non-sqlite projects

Reported by: Thijs Triemstra Owned by: Thijs Triemstra
Priority: high Milestone: 1.0
Component: admin/console Version: 0.11-stable
Severity: normal Keywords: bitesized, patch, mysql, postgresql
Cc: Branch:
Release Notes:

Back up the database during a trac-admin $ENV hotcopy, on all backends.

API Changes:
Internal Changes:

Description

Would be nice to have a mysql/postgress db dump when using trac-admin ENV hotcopy DEST. We already have all the necessary functionality, as we do a backup during upgrades. We could store the dump in the ENV/db directory before the copy operation.

From #8952

Attachments (3)

sql-hotcopy-8954.patch (1.1 KB ) - added by Thijs Triemstra 14 years ago.
against 0.12-stable r10370
sql-hotcopy-8954-2.patch (1.5 KB ) - added by Thijs Triemstra 14 years ago.
sql-hotcopy-8954-3.patch (3.7 KB ) - added by Thijs Triemstra 14 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 by Remy Blank, 15 years ago

Milestone: next-minor-0.12.x

comment:2 by Remy Blank, 15 years ago

Keywords: bitesized added

comment:3 by Christian Boos, 15 years ago

Priority: normalhigh

comment:4 by Christian Boos, 15 years ago

Milestone: next-minor-0.12.xunscheduled

comment:5 by anonymous, 14 years ago

Agreed, this would be rad!

comment:6 by Thijs Triemstra, 14 years ago

Reporter: changed from Thijs Triemstra <lists@…> to Thijs Triemstra

by Thijs Triemstra, 14 years ago

Attachment: sql-hotcopy-8954.patch added

against 0.12-stable r10370

comment:7 by Thijs Triemstra, 14 years ago

Keywords: patch added
Owner: set to Thijs Triemstra
Status: newassigned
Summary: trac-admin hotcopy should export database dump for non-sqlite projects[PATCH] trac-admin hotcopy should export database dump for non-sqlite projects

The attached patch creates a 'db-backup.sql' in the environment folder which get copied in the hotcopy destination folder. MySQL trac installations don't have a db folder so I copied it to the root of the environment. Maybe a db folder for non-sqlite backups should be made when using hotcopy that can hold the .sql file?

comment:8 by Remy Blank, 14 years ago

Milestone: unscheduled0.13

A db folder even for non-SQLite backends would make sense, yes. However, shouldn't the dump rather be placed into a db folder of the destination instead of the source, probably after the copytree() call? That would avoid having a possibly large file (the dump of t.e.o is over 2 GB) placed twice in the filesystem.

by Thijs Triemstra, 14 years ago

Attachment: sql-hotcopy-8954-2.patch added

in reply to:  8 ; comment:9 by Thijs Triemstra, 14 years ago

Replying to rblank:

A db folder even for non-SQLite backends would make sense, yes. However, shouldn't the dump rather be placed into a db folder of the destination instead of the source, probably after the copytree() call? That would avoid having a possibly large file (the dump of t.e.o is over 2 GB) placed twice in the filesystem.

The attached patch creates a db folder where the sql dump is created. I was wondering if a cmdline option like --no-database (to exclude the db export for hotcopy) or --database (to include the db export for hotcopy)? With 2GB databases the user might want to skip the export db option?

in reply to:  9 ; comment:10 by Remy Blank, 14 years ago

Replying to thijstriemstra:

I was wondering if a cmdline option like --no-database (to exclude the db export for hotcopy) or --database (to include the db export for hotcopy)? With 2GB databases the user might want to skip the export db option?

That's a good idea indeed. Probably --no-database, so that it's included by default.

in reply to:  10 comment:11 by Thijs Triemstra, 14 years ago

Replying to rblank:

That's a good idea indeed. Probably --no-database, so that it's included by default.

Sounds good. I guess a status message (Exporting database…) might be useful as well, I reckon it takes quite a while to export a 2GB db, and without such a message users might think hotcopy crashed or died.

Last edited 14 years ago by Thijs Triemstra (previous) (diff)

by Thijs Triemstra, 14 years ago

Attachment: sql-hotcopy-8954-3.patch added

comment:12 by Thijs Triemstra, 14 years ago

The attached patch adds the ability to ignore the database export (inc sqlite) using the --no-database or -d flag. For example:

trac-admin ../test2 hotcopy ../testerr/
Hotcopying /Users/thijstriemstra/Sites/projects/opensource/test2 to ../testerr/ ...
Exporting database...
Hotcopy done.

Without database:

trac-admin ../test2 hotcopy ../testerr/ --no-database
Hotcopying /Users/thijstriemstra/Sites/projects/opensource/test2 to ../testerr/ ...
Hotcopy done.

comment:13 by Thijs Triemstra, 14 years ago

Keywords: mysql postgresql added

comment:14 by Remy Blank, 14 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Patch applied in [10387] with very minor changes:

  • DatabaseManager.backup() already creates the destination directory if it doesn't exist, so there's no need to do it in _do_hotcopy().
  • For SQLite, exclude only the database file if --no-database is specified, not the complete db directory, as it could contain other files (e.g. backups from upgrades).
  • Removed the short form of the --no-database option.

Thanks for your great work!

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Thijs Triemstra.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Thijs Triemstra to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.