#!/bin/bash set -e for i in {1..20}; do i3-resurrect save -w $i --swallow=class,instance,title done backupdir=~/.i3/i3-resurrect-backups keep_backups=30 mkdir -p "$backupdir" cp -r ~/.i3/i3-resurrect $backupdir/0 if [[ -d "$backupdir/$keep_backups" ]]; then rm -rf "$backupdir/$keep_backups" fi i=$((keep_backups - 1)) while ((i >= 0)); do if [[ -d "$backupdir/$i/" ]]; then mv -n "$backupdir/$i/" "$backupdir/$((i + 1))"/ fi i=$((i - 1)) done