#! /usr/bin/env python
import sys
def main():
print "SET sql_mode='NO_BACKSLASH_ESCAPES';"
lines = sys.stdin.read().splitlines()
for line in lines:
processLine(line)
def processLine(line):
if (
line.startswith("PRAGMA") or
line.startswith("BEGIN TRANSACTION;") or
line.startswith("COMMIT;") or
line.startswith("DELETE FROM sqlite_sequence;") or
line.startswith("INSERT INTO \"sqlite_sequence\"")
):
return
line = line.replace("AUTOINCREMENT", "AUTO_INCREMENT")
line = line.replace("DEFAULT 't'", "DEFAULT '1'")
line = line.replace("DEFAULT 'f'", "DEFAULT '0'")
line = line.replace(",'t'", ",'1'")
line = line.replace(",'f'", ",'0'")
in_string = False
newLine = ''
for c in line:
if not in_string:
if c == "'":
in_string = True
elif c == '"':
newLine = newLine + '`'
continue
elif c == "'":
in_string = False
newLine = newLine + c
print newLine
if __name__ == "__main__":
main()
:wq
#
$ mysql -u root -p
Password: ****
mysql> drop database bitnami_redmine;
mysql> create database bitnami_redmine;
mysql> grant all privileges on bitnami_redmine.* to 'bn_redmine'@'localhost' identified by 'DATABASE_PASSWORD';
# with below commands
sqlite3 /var/www/redmine/db/redmine_development.sqlite3 '.dump' | ./sqlitetomysql.py > redmine_db.sql
mysql -u root -p'mysql@123' redmine_db < /root/redmine_db.sql
Migrate the database to the latest version:
$ cd /opt/bitnami/apps/redmine/htdocs
$ ruby bin/rake db:migrate RAILS_ENV=production
Copy the ""/opt/bitnami/apps/redmine/htdocs/files" folder from the old installation to the new one.
If you have installed plugins in the previous version, copy the folders from "vendor/plugins" directory into new installation directory, in "plugins" folder.
Check the plugins also support this new version and run the following command
$ ruby bin/rake redmine:plugins RAILS_ENV=production
Finally you should clean the cache and the sessions:
$ ruby bin/rake tmp:cache:clear
$ ruby bin/rake tmp:sessions:clear
Ref:
https://wiki.bitnami.com/Applications/BitNami_Redmine#Backup
import sys
def main():
print "SET sql_mode='NO_BACKSLASH_ESCAPES';"
lines = sys.stdin.read().splitlines()
for line in lines:
processLine(line)
def processLine(line):
if (
line.startswith("PRAGMA") or
line.startswith("BEGIN TRANSACTION;") or
line.startswith("COMMIT;") or
line.startswith("DELETE FROM sqlite_sequence;") or
line.startswith("INSERT INTO \"sqlite_sequence\"")
):
return
line = line.replace("AUTOINCREMENT", "AUTO_INCREMENT")
line = line.replace("DEFAULT 't'", "DEFAULT '1'")
line = line.replace("DEFAULT 'f'", "DEFAULT '0'")
line = line.replace(",'t'", ",'1'")
line = line.replace(",'f'", ",'0'")
in_string = False
newLine = ''
for c in line:
if not in_string:
if c == "'":
in_string = True
elif c == '"':
newLine = newLine + '`'
continue
elif c == "'":
in_string = False
newLine = newLine + c
print newLine
if __name__ == "__main__":
main()
:wq
#
$ mysql -u root -p
Password: ****
mysql> drop database bitnami_redmine;
mysql> create database bitnami_redmine;
mysql> grant all privileges on bitnami_redmine.* to 'bn_redmine'@'localhost' identified by 'DATABASE_PASSWORD';
# with below commands
sqlite3 /var/www/redmine/db/redmine_development.sqlite3 '.dump' | ./sqlitetomysql.py > redmine_db.sql
mysql -u root -p'mysql@123' redmine_db < /root/redmine_db.sql
Migrate the database to the latest version:
$ cd /opt/bitnami/apps/redmine/htdocs
$ ruby bin/rake db:migrate RAILS_ENV=production
Copy the ""/opt/bitnami/apps/redmine/htdocs/files" folder from the old installation to the new one.
If you have installed plugins in the previous version, copy the folders from "vendor/plugins" directory into new installation directory, in "plugins" folder.
Check the plugins also support this new version and run the following command
$ ruby bin/rake redmine:plugins RAILS_ENV=production
Finally you should clean the cache and the sessions:
$ ruby bin/rake tmp:cache:clear
$ ruby bin/rake tmp:sessions:clear
Ref:
https://wiki.bitnami.com/Applications/BitNami_Redmine#Backup
No comments:
Post a Comment