<@U0A71G31CDV> Does StarRocks backup jobs need roo...
# questions-and-troubleshooting
m
@Rocky Does StarRocks backup jobs need root user? I've already created the repository. My cron job just runs the create snapshot command.
r
StarRocks backup jobs do not strictly require the
root
user, provided the user running the job has the necessary privileges. Since you have already created the repository (which does require
ADMIN
privileges), you can use a less-privileged user for the recurring backup jobs. The required privileges for the
BACKUP
command depend on your StarRocks version: StarRocks v3.0 and later You can create a dedicated backup user and grant it the following privileges: 1. REPOSITORY privilege on the
SYSTEM
level. 2. EXPORT privilege on the specific tables or databases you are backing up. Example for a specific database:
Copy code
sql
-- 1. Create a role for backup
CREATE ROLE backup_role;

-- 2. Grant system-level repository access
GRANT REPOSITORY ON SYSTEM TO ROLE backup_role;

-- 3. Grant export access to the target database
GRANT EXPORT ON ALL TABLES IN DATABASE <your_db_name> TO ROLE backup_role;

-- 4. Assign role to your cron user
GRANT backup_role TO USER 'your_cron_user'@'%';
StarRocks versions earlier than v3.0 In older versions, the user must have the
admin_priv
privilege. While the
root
user has this by default, you can grant it to any other user:
Copy code
sql
GRANT ADMIN ON SYSTEM TO USER 'your_cron_user'@'%';
Important Notes * Restore Privileges: If your cron job also handles RESTORE operations, that user will need additional privileges such as
CREATE DATABASE
,
CREATE TABLE
, and
INSERT
to recreate the data in the target environment. * Job Limits: Only one
BACKUP
or
RESTORE
job can run at a time per database. If you have multiple databases, you must schedule them or wait for the previous one to finish. Referencessql-reference/sql-statements/backup_restore/CREATE_REPOSITORY.mdadministration/cluster_snapshot.mdsql-reference/sql-statements/backup_restore/BACKUP.mdadministration/user_privs/authorization/User_privilege.mdadministration/user_privs/authorization/privilege_item.mdadministration/management/Backup_and_restore.md