Culling

Thin out the snapshots on disk.

snapintime.culling.btrfs_del(directory: str, subvols: list) → list

Delete subvolumes in a given directory.

Parameters
  • directory – The directory holding the subvolumes.

  • subvols – A list of subvolumes to delete

Returns

A list with the commands run and the results or, if there weren’t any subvolumes to delete, returns a message with that information.

snapintime.culling.cull_last_quarter(config: dict) → list

Cull the btrfs snapshots from quarter.

Should leave 1 snapshot per week for 13 weeks.

Parameters

config – The configuration file.

Returns

A list containing the results of running the commands.

snapintime.culling.cull_last_year(config: dict) → list

Cull the btrfs snapshots from quarter.

Should leave 1 snapshot per week for 13 weeks.

Parameters

config – The configuration file.

Returns

A list containing the results of running the commands.

snapintime.culling.cull_seven_days_ago(config: dict) → list

Cull the btrfs snapshots from 7 days ago.

Parameters

config – The configuration file.

Returns

A list containing the results of running the commands.

snapintime.culling.cull_three_days_ago(config: dict) → list

Cull the btrfs snapshots from 3 days ago.

Parameters

config – The configuration file.

Returns

A list containing the results of running the commands.

snapintime.culling.daily_cull(dir_to_cull: list) → list

Take a list of snapshots from a directory (already reduced to one day) and cull.

This culling will produce the closest it can to 4 snapshots for that day.

For a perfect set of 24 snapshots, it should leave behind (remove from list):

  • day1-0000

  • day1-0600

  • day1-1200

  • day1-1800

Parameters

dir_to_cull – A list containing snapshots. Assumes another function has already reduced this list to a list containing only one day’s worth of snapshots.

Returns

A list containing all the subvolumes to cull.

snapintime.culling.get_subvols_by_date(directory: str, reg_ex) → list

Return a list based on matching regular expression.

This is meant to produce the list that will be the input for one of the culling functions.

Parameters
  • directory – The directory we want to grab subvols from.

  • reg_ex – A regular expression to apply to the directory contents.

Returns

A list of subvolumes for culling.

snapintime.culling.main()
snapintime.culling.print_output(list_of_lists: list)
snapintime.culling.quarterly_yearly_cull(dir_to_cull: list) → list

Take a list of snapshots from a directory (already reduced to one week or quarter) and cull.

This culling will return a list with the snapshots to remove for the week or quarter.

For a perfect set of snapshots, (where the user has been doing one snapshot per hour and doing the daily culling) it should leave behind (remove from list):

  • day7-1800

Note

May end up combining with weekly cull as they essentially do the same thing.

Parameters

dir_to_cull – A list containing snapshots. Assumes another function has already reduced this list to a list containing only one week or quarter’s worth of snapshots.

Returns

A list containing all the subvolumes to cull.

snapintime.culling.split_dir_hours(subvols: list, reg_ex) → list

Return a list based on matching regular expression.

Parameters
  • subvols – A list of subvolumes.

  • reg_ex – A re object defining the regular expression to evaluate against.

Returns

A list that has only the items that passed the regular expression.

snapintime.culling.weekly_cull(dir_to_cull: list) → list

Take a list of snapshots from a directory (already reduced to one day) and cull.

This culling will return a list with the snapshots to remove for the given day.

For a perfect set of snapshots, (where the user has been doing one snapshot per hour and doing the daily culling) it should leave behind (remove from list):

  • day1-1800

Parameters

dir_to_cull – A list containing snapshots. Assumes another function has already reduced this list to a list containing only one day’s worth of snapshots.

Returns

A list containing all the subvolumes to cull.