732 config.quick_start = True |
732 config.quick_start = True |
733 mih = config.migration_handler(connect=False, verbosity=1) |
733 mih = config.migration_handler(connect=False, verbosity=1) |
734 mih.backup_database(output, askconfirm=False, format=format) |
734 mih.backup_database(output, askconfirm=False, format=format) |
735 mih.shutdown() |
735 mih.shutdown() |
736 |
736 |
737 def _local_restore(appid, backupfile, drop, systemonly=True, format='native'): |
737 def _local_restore(appid, backupfile, drop, format='native'): |
738 config = ServerConfiguration.config_for(appid) |
738 config = ServerConfiguration.config_for(appid) |
739 config.verbosity = 1 # else we won't be asked for confirmation on problems |
739 config.verbosity = 1 # else we won't be asked for confirmation on problems |
740 config.quick_start = True |
740 config.quick_start = True |
741 mih = config.migration_handler(connect=False, verbosity=1) |
741 mih = config.migration_handler(connect=False, verbosity=1) |
742 mih.restore_database(backupfile, drop, systemonly, askconfirm=False, format=format) |
742 mih.restore_database(backupfile, drop, askconfirm=False, format=format) |
743 repo = mih.repo_connect() |
743 repo = mih.repo_connect() |
744 # version of the database |
744 # version of the database |
745 dbversions = repo.get_versions() |
745 dbversions = repo.get_versions() |
746 mih.shutdown() |
746 mih.shutdown() |
747 if not dbversions: |
747 if not dbversions: |
846 ('no-drop', |
846 ('no-drop', |
847 {'short': 'n', 'action' : 'store_true', 'default' : False, |
847 {'short': 'n', 'action' : 'store_true', 'default' : False, |
848 'help': 'for some reason the database doesn\'t exist and so ' |
848 'help': 'for some reason the database doesn\'t exist and so ' |
849 'should not be dropped.'} |
849 'should not be dropped.'} |
850 ), |
850 ), |
851 ('restore-all', |
|
852 {'short': 'r', 'action' : 'store_true', 'default' : False, |
|
853 'help': 'restore everything, eg not only the system source database ' |
|
854 'but also data for all sources supporting backup/restore and custom ' |
|
855 'instance data. In that case, <backupfile> is expected to be the ' |
|
856 'timestamp of the backup to restore, not a file'} |
|
857 ), |
|
858 ('format', |
851 ('format', |
859 {'short': 'f', 'default': 'native', 'type': 'choice', |
852 {'short': 'f', 'default': 'native', 'type': 'choice', |
860 'choices': ('native', 'portable'), |
853 'choices': ('native', 'portable'), |
861 'help': 'the format used when dumping the database'}), |
854 'help': 'the format used when dumping the database'}), |
862 ) |
855 ) |
872 # continue if the command exited with status 0 (success) |
865 # continue if the command exited with status 0 (success) |
873 if exc.code: |
866 if exc.code: |
874 raise |
867 raise |
875 _local_restore(appid, backupfile, |
868 _local_restore(appid, backupfile, |
876 drop=not self.config.no_drop, |
869 drop=not self.config.no_drop, |
877 systemonly=not self.config.restore_all, |
|
878 format=self.config.format) |
870 format=self.config.format) |
879 if self.config.format == 'portable': |
871 if self.config.format == 'portable': |
880 try: |
872 try: |
881 CWCTL.run(['db-rebuild-fti', appid]) |
873 CWCTL.run(['db-rebuild-fti', appid]) |
882 except SystemExit as exc: |
874 except SystemExit as exc: |