protected function doBackupCustomLocationAliases()
    {
        $totalCount = $this->getTotalLocationCount();
        $passCount = ceil($totalCount / $this->bulkCount);
        $customAliasCount = 0;
        $customAliasPathCount = 0;

        if ($totalCount === 0) {
            $this->output->writeln('Could not find any Locations, nothing to backup.');
            $this->output->writeln('');

            return;
        }

        $queryBuilder = $this->connection->createQueryBuilder();
        $queryBuilder
            ->select('node_id', 'parent_node_id', 'contentobject_id')
            ->from('ezcontentobject_tree')
            ->where($queryBuilder->expr()->neq('node_id', 1))
            ->orderBy('depth', 'ASC')
            ->addOrderBy('node_id', 'ASC');

        $this->output->writeln("Backing up custom URL alias(es) for {$totalCount} Location(s).");

        $progressBar = $this->getProgressBar($totalCount);
        $progressBar->start();

        for ($pass = 0; $pass <= $passCount; ++$pass) {
            $rows = $this->loadLocationData($queryBuilder, $pass);

            foreach ($rows as $row) {
                $customAliases = $this->urlAliasHandler->listURLAliasesForLocation(
                    $row['node_id'],
                    true
                );

                $customAliasCount += count($customAliases);
                $customAliasPathCount += $this->storeCustomAliases($customAliases);
            }

            $progressBar->advance(count($rows));
        }

        $progressBar->finish();

        $this->output->writeln('');
        $this->output->writeln(
            "Done. Backed up {$customAliasCount} custom URL alias(es) " .
            "with {$customAliasPathCount} path(s)."
        );
        $this->output->writeln('');
    }