Gitlab Restore through Auto-scaling user data

Hello, so I’m trying to automate restoring a GitLab backup using a user data script on an EC2 instance. When I run the restore script (gitlab_restore.sh) manually, everything works fine and my repo is restored. But when I try to run it automatically through the user data script, it doesn’t restore the repo even though the backup file gets used. It seems like the restore process starts, but something goes wrong when it’s run automatically. I need help figuring out why this is happening and how to fix it.
P.S: The backup is located in an EBS Volume that gets mounted on the instance at boot and works fine.