Skip to content

Commit

Permalink
cluster-backup. Preserve list order
Browse files Browse the repository at this point in the history
Items returned by Redis lists are randomly sorted. Ensure the same items
order is dumped to backup to avoid generating different versions of the
dump for the same data.
  • Loading branch information
DavidePrincipi committed Jan 29, 2024
1 parent 431b02b commit 924037a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/imageroot/var/lib/nethserver/cluster/bin/cluster-backup
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ for k in ['network', 'ui_name', 'uuid']:
dump['cluster'][k] = rdb.get(f'cluster/{k}') or ''

# cluster: favorite apps
dump['cluster']['favorites'] = list(rdb.smembers(f'cluster/favorites'))
dump['cluster']['favorites'] = sorted(rdb.smembers(f'cluster/favorites'))

# cluster: module URL override
dump['cluster']['override']['modules'] = rdb.hgetall('cluster/override/modules')
Expand All @@ -86,7 +86,7 @@ for m in rdb.scan_iter('module/*/backups'):
k = m.removeprefix('module/').removesuffix('/backups')
uuid = rdb.hget(f'module/{k}/environment', 'MODULE_UUID')
dump['modules'][uuid] = {'backups': []}
dump['modules'][uuid]['backups'] = list(rdb.smembers(m))
dump['modules'][uuid]['backups'] = sorted(rdb.smembers(m))

# nodes: vpn, label
for v in rdb.scan_iter('node/*/vpn'):
Expand Down

0 comments on commit 924037a

Please sign in to comment.