fix issues when :memory: was used + function to copy database