fixed database restore on remote app
further improving the sync script