return buffer;
}
-static int __archive(struct volume_group *vg)
+static int _archive(struct volume_group *vg, int compulsory)
{
char *desc;
- if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 1)))
- return_0;
-
- return archive_vg(vg, vg->cmd->archive_params->dir, desc,
- vg->cmd->archive_params->keep_days,
- vg->cmd->archive_params->keep_number);
-}
-
-int archive(struct volume_group *vg)
-{
/* Don't archive orphan VGs. */
if (is_orphan_vg(vg->name))
return 1;
return 1;
}
- if (!dm_create_dir(vg->cmd->archive_params->dir))
- return 0;
+ if (!dm_create_dir(vg->cmd->archive_params->dir)) {
+ /* FIXME: !compulsory logs error here */
+ log_error("Cannot create archiving directory %s.",
+ vg->cmd->archive_params->dir);
+ return compulsory ? 0 : 1;
+ }
/* Trap a read-only file system */
if ((access(vg->cmd->archive_params->dir, R_OK | W_OK | X_OK) == -1) &&
- (errno == EROFS))
- return 0;
+ (errno == EROFS)) {
+ /* FIXME: !compulsory logs error here */
+ log_error("Cannot archive volume group metadata for %s to read-only filesystem.",
+ vg->name);
+ return compulsory ? 0 : 1;
+ }
log_verbose("Archiving volume group \"%s\" metadata (seqno %u).", vg->name,
vg->seqno);
- if (!__archive(vg)) {
- log_error("Volume group \"%s\" metadata archive failed.",
- vg->name);
- return 0;
- }
+
+ if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 1)))
+ return_0;
+
+ if (!archive_vg(vg, vg->cmd->archive_params->dir, desc,
+ vg->cmd->archive_params->keep_days,
+ vg->cmd->archive_params->keep_number))
+ return_0;
vg->status |= ARCHIVED_VG;
return 1;
}
+int archive(struct volume_group *vg)
+{
+ return _archive(vg, 1);
+}
+
int archive_display(struct cmd_context *cmd, const char *vg_name)
{
int r1, r2;
cmd->backup_params->enabled = flag;
}
-static int __backup(struct volume_group *vg)
+static int _backup(struct volume_group *vg)
{
char name[PATH_MAX];
char *desc;
/* Trap a read-only file system */
if ((access(vg->cmd->backup_params->dir, R_OK | W_OK | X_OK) == -1) &&
- (errno == EROFS))
+ (errno == EROFS)) {
+ log_warn("WARNING: Cannot backup of volume group %s metadata to read-only fs.",
+ vg->name);
return 0;
+ }
- if (!__backup(vg)) {
+ if (!_backup(vg)) {
log_error("Backup of volume group %s metadata failed.",
vg->name);
return 0;
return;
if (dm_snprintf(path, sizeof(path), "%s/%s",
- vg->cmd->backup_params->dir, vg->name) < 0) {
- log_debug("Failed to generate backup filename.");
+ vg->cmd->backup_params->dir, vg->name) < 0) {
+ log_warn("WARNING: Failed to generate backup pathname %s/%s.",
+ vg->cmd->backup_params->dir, vg->name);
return;
}
log_suppress(old_suppress);
if (vg_backup) {
- if (!archive(vg_backup))
+ if (!_archive(vg_backup, 0))
stack;
release_vg(vg_backup);
}
- if (!archive(vg))
+ if (!_archive(vg, 0))
stack;
if (!backup_locally(vg))
stack;