Converting DB Type with single command


I try to convert my DB from SQLite to MySQL using this procedure Converting Database Type

Problem is, my nextcloud runs on a shared server and I don’t have access to a command shell.

However, I can execute command via task scheduler (i.e. crontab) and by using the FileMan application. So, in general I could execute arbitrary commands but not interactive.

Is there any possibility to run php occ db:convert-type mysql username hostname database without confirmation “yes” - e.g. --force option?

I tried already

echo yes | php occ db:convert-type mysql username hostname database >> occ.out  2>&1


php occ db:convert-type type username hostname database <<< yes >> occ.out  2>&1 

but they are not working.

All I get is

Creating schema in new database
The following tables will not be converted:

but then it stops.

Best Regards

1 Like

Have you tried to use the -n, --no-interaction flag of the occ command?
php occ -n db:convert-type [...]

No, --no-interaction does not help. I get the same output and DB is not converted.

The script creates tables but no data is migrated. Only in table oc_migrations I get 28 records but nothing else is migrated.

I just tried the conversion on a testing instance (Nextcloud 14.0.0) and the flag -n doesn‘t seem to work. I only get the same output like you and then it stops. This looks like a bug to me.

If you run that command multiple times, it is important to use option --clear-schema, otherwise the command will exit with an error, because the tables are already existing.

Which version of Nextcloud are you using? I‘d like to try on my testing instance.

EDIT: I just found out that the command stops, if yes is entered (like stated in the documentation). It runs through when confirming with y. So maybe try your command with piping y instead of yes to it.

No, echo y (and echo -e "y\n") does not help either.

I am using the latest stable build 14.0.3


Another approach would be to disable the confirmation question by temporarily commenting out lines 215-220 in file /path/to/nextcloud/core/Command/Db/ConvertType.php ( Just add a double slash // at the beginning of those lines. Maybe that is easier than fiddling around with pipes and stuff.

Don’t forget to do a backup of the sqlite-database (owncloud.db in the data-folder) and the config.php before.

Actually that was my first idea but I did not find it (I did not spend so much time for it).

I changed it properly to this:

if (!$input->getOption('no-interaction')) {
	$helper = $this->getHelper('question');
	$question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false);

	if (!$helper->ask($input, $output, $question)) {

Conversion to MySQL was running fine!

Thank you

1 Like