mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
restore: Add option --numeric-id
This commit is contained in:
parent
739b207441
commit
68d28b413a
@ -193,11 +193,9 @@ impl LocalBackend {
|
||||
fs::create_dir(&dirname).unwrap();
|
||||
}
|
||||
|
||||
// TODO: times
|
||||
pub fn set_user_group(&self, item: impl AsRef<Path>, meta: &Metadata) {
|
||||
let filename = self.path.join(item);
|
||||
|
||||
// set uid/gid
|
||||
let user = meta
|
||||
.user
|
||||
.as_ref()
|
||||
@ -216,6 +214,15 @@ impl LocalBackend {
|
||||
chown(&filename, uid, gid).unwrap();
|
||||
}
|
||||
|
||||
pub fn set_uid_gid(&self, item: impl AsRef<Path>, meta: &Metadata) {
|
||||
let filename = self.path.join(item);
|
||||
|
||||
let uid = meta.uid.map(Uid::from_raw);
|
||||
let gid = meta.gid.map(Gid::from_raw);
|
||||
|
||||
chown(&filename, uid, gid).unwrap();
|
||||
}
|
||||
|
||||
pub fn set_permission(&self, item: impl AsRef<Path>, meta: &Metadata) {
|
||||
let filename = self.path.join(item);
|
||||
|
||||
|
||||
@ -26,6 +26,10 @@ pub(super) struct Opts {
|
||||
#[clap(long)]
|
||||
delete: bool,
|
||||
|
||||
/// use numeric ids instead of user/groug when restoring uid/gui
|
||||
#[clap(long)]
|
||||
numeric_id: bool,
|
||||
|
||||
/// snapshot to restore
|
||||
id: String,
|
||||
|
||||
@ -151,7 +155,11 @@ async fn restore_metadata(
|
||||
while let Some((path, node)) = node_streamer.try_next().await? {
|
||||
if !opts.dry_run {
|
||||
dest.create_special(&path, &node);
|
||||
dest.set_user_group(&path, node.meta());
|
||||
if opts.numeric_id {
|
||||
dest.set_uid_gid(&path, node.meta());
|
||||
} else {
|
||||
dest.set_user_group(&path, node.meta());
|
||||
}
|
||||
dest.set_permission(&path, node.meta());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user