Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [Solved] CP Errors when Backing Up /var/cache/pacman/pkg (Read 2630 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

[Solved] CP Errors when Backing Up /var/cache/pacman/pkg

Since I've moved to Artix and learning about where the packages are stored, I decided to make them a part of my files to be backed up.

I have experienced a problem while backing up the files.

Code: [Select]
# cp -r /var/cache/pacman/pkg /run/media/tsedek1/unique-dev-id/Downloads/

These are the errors I get for some of the files:
Code: [Select]
cp: cannot create regular file '/run/media/tsedek1/unique-dev-id/Downloads/arch/pkg/nftables-1:1.1.1-2-x86_64.pkg.tar.zst.sig': Invalid argument
cp: cannot create regular file '/run/media/tsedek1/unique-dev-id/Downloads/arch/pkg/iptables-1:1.8.11-2-x86_64.pkg.tar.zst': Invalid argument
cp: cannot create regular file '/run/media/tsedek1/unique-dev-id/Downloads/arch/pkg/iptables-1:1.8.11-2-x86_64.pkg.tar.zst.sig': Invalid argument
cp: cannot create regular file '/run/media/tsedek1/unique-dev-id/Downloads/arch/pkg/libadwaita-1:1.7.0-2-x86_64.pkg.tar.zst': Invalid argument
cp: cannot create regular file '/run/media/tsedek1/unique-dev-id/Downloads/arch/pkg/libadwaita-1:1.7.0-2-x86_64.pkg.tar.zst.sig': Invalid argument
cp: cannot create regular file '/run/media/tsedek1/unique-dev-id/Downloads/arch/pkg/libgovirt-2:0.3.9-2-x86_64.pkg.tar.zst': Invalid argument

Sometimes it copies the files changing the : into _, but not always. Currently, cp doesn't copy the : files at all.
Apparently, colons are a command argument.
How can I backup these files without the 'Invalid argument'?

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #1
Tried this variation with no luck:
Code: [Select]
# cp -a /var/cache/pacman/pkg /run/media/tsedek1/unique-dev-id/Downloads/arch/
 cp: failed to preserve ownership for '/run/media/tsedek1/unique-dev-id/Downloads/arch/pkg/gcc-14.2.1+r753+g1cd744a6828f-1-x86_64.pkg.tar.zst': Operation not permitted

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #2
The error probably means the filenames are illegal for the target filesystem.

You could create a different filesystem on the backup drive.

Or, you could tar the entire cache directory and give the tarball a simpler name.

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #3
The error probably means the filenames are illegal for the target filesystem.

You could create a different filesystem on the backup drive.

Or, you could tar the entire cache directory and give the tarball a simpler name.
I didn't know FAT was an illegal file system.

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #4
Tried this as a solution:
Code: [Select]
-t, --target-directory=DIRECTORY
    copy all SOURCE arguments into DIRECTORY
Did not work. It copied all of the files except for file names with colons.
Additionally, it left the target directory open, not closing the folder and provided no errors.

Tried this one because it appears to preserve file names:
Code: [Select]
--parents
    use full source file name under DIRECTORY
Unfortunately this copies parent directories from the current directory.
So when, 'cp /var/cache/pacman/pkg' it will copy everything up to and including '/var'

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #5
Looks like it's baked in:
Code: [Select]
// We use `:` as a delimiter between CONTAINER and PATH, but `:` could also be
// in a valid LOCALPATH, like `file:name.txt`. We can resolve this ambiguity by
// requiring a LOCALPATH with a `:` to be made explicit with a relative or
// absolute path:
// `/path/to/file:name.txt` or `./file:name.txt`
//
// This is apparently how `scp` handles this as well:
// http://www.cyberciti.biz/faq/rsync-scp-file-name-with-colon-punctuation-in-it/
//
// We can't simply check for a filepath separator because container names may
// have a separator, e.g., "host0/cname1" if container is in a Docker cluster,
// so we have to check for a `/` or `.` prefix. Also, in the case of a Windows
// client, a `:` could be part of an absolute Windows path, in which case it
// is immediately proceeded by a backslash
According to: https://github.com/docker/cli/issues/1125

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #6
Why are you asking questions here if you refuse to read and accept the answers? You make it sound like this is something complicated about using the cp command correctly. It's not.

FAT is an ancient file system that does not support very long or complex filenames. That is your only problem here. Apart from renaming the individual files, you have the two options I offered for how to easily resolve this.

Is there a reason you need this backup to be readable on a Windows machine or something?

 

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #7
Code: [Select]
$ tar -cvf /tmp/pkgcache.tar /var/cache/pacman/pkg/ && cp /tmp/pkgcache.tar /path/to/Microsoftformattedbackupdrive && rm /tmp/pkgcache.tar
The tar ball achive will preserve the original file names but allow the whole thing to be copied across, also it can sometimes be faster to copy a single large file than many small ones. The packages are already compressed so you don't need to add a compression flag.
NTFS has the same illegal characters, it's a Windows thing, built in to the destination file system. You could also reformat the backup drive to a Linux filesystem like ext4 or btrfs. And there are some methods to rename files, there are numerous suggestions how to do this online like here:
https://superuser.com/questions/178025/linux-copy-to-fat32-filesystem-invalid-argument
Although I would imagine for the purpose of a backup it would probably be better to use tar as suggested by lotuskip and not change the names.
You should be able to find old packages in the Artix package archives so depending on what you have in mind, you may not need to save them locally either.

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #8
Why are you asking questions here if you refuse to read and accept the answers? You make it sound like this is something complicated about using the cp command correctly. It's not.

FAT is an ancient file system that does not support very long or complex filenames. That is your only problem here. Apart from renaming the individual files, you have the two options I offered for how to easily resolve this.

Is there a reason you need this backup to be readable on a Windows machine or something?
CP is not working as I would expect. Anything with file name should not be ignored because it can't be anything other than a filename.
Also:
There is no consensus on why it doesn't work. Some suggest Windows file names, while others point to File Systems.
But, looking at the Docker explanation, it appears the colon is baked into cp to help Docker with their structure.

I'm not into Eugenics. Windows is built by a death cult. I don't support anyone who uses Windows.

On a less assaultive note.. tar -cf pkg seems to work well enough. A few extra steps, but it works.

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #9
Code: [Select]
$ tar -cvf /tmp/pkgcache.tar /var/cache/pacman/pkg/ && cp /tmp/pkgcache.tar /path/to/Microsoftformattedbackupdrive && rm /tmp/pkgcache.tar
The tar ball achive will preserve the original file names but allow the whole thing to be copied across, also it can sometimes be faster to copy a single large file than many small ones. The packages are already compressed so you don't need to add a compression flag.
NTFS has the same illegal characters, it's a Windows thing, built in to the destination file system. You could also reformat the backup drive to a Linux filesystem like ext4 or btrfs. And there are some methods to rename files, there are numerous suggestions how to do this online like here:
https://superuser.com/questions/178025/linux-copy-to-fat32-filesystem-invalid-argument
Although I would imagine for the purpose of a backup it would probably be better to use tar as suggested by lotuskip and not change the names.
You should be able to find old packages in the Artix package archives so depending on what you have in mind, you may not need to save them locally either.

I have found I like backing up the pkg files. It gives me the ability to install offline. Currently I'm learning how to install packages with dependencies.
Code: [Select]
~# pacman -U /var/cache/pacman/pkg/nushell-0.103.0-1-x86_64.pkg.tar.zst

It saves from having to download a gig or more of files. When I already have them pacman installs what is present and only downloads what it needs, like files not in the pkg directory or new versions.
Security wise it's a benefit, being able to do most installs without an internet, where the attackers live.
It's a Linux all the way around.

I install Auditd and nftables, configure them, before ever connecting.

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #10
CP is not working as I would expect. Anything with file name should not be ignored because it can't be anything other than a filename.
Also:
There is no consensus on why it doesn't work. Some suggest Windows file names, while others point to File Systems.
Your brain is not working as I would expect.
You've been told. You can't have colons in FAT filenames.
You were trying to copy files with colons in the filename to a FAT filesystem.
It won't work.

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #11
A file system is a data structure written to a blank drive, which provides something like a contents page or index in a book, to access the data throughout. The file names are recorded in this index. Microsoft Windows has different rules to Linux regarding what characters can be used to name the files, so any Microsoft file system like FAT or NTFS has to obey these rules, even if it is being accessed from Linux, because Linux is only interfacing with what is already on the drive. Besides the character restrictions in the file names, MS file systems also don't support Linux file permissions, so that information will be lost too unless you wrap files in a tar archive first.

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #12
it wouldn't be a bad idea to learn about tar and rsync

Re: CP Errors when Backing Up /var/cache/pacman/pkg

Reply #13
it wouldn't be a bad idea to learn about tar and rsync

Code: [Select]
~$ tar -cf pkg

...is working well. A few extra steps, but it's working.

nushell has columns...But, 'Detect Columns' doesn't work on the audit.log files.

Code: [Select]
pacman -U /var/cache/pacman/pkg/nushell-0.103.0-1-x86_64.pkg.tar.zst
;D

I don't think I'm interested in 'rsync' at this time. I'm trying to prevent shenanigans.sh from being installed, so am weary of network related apps ATM.
After I learn to lock this thing down, like limit remote root, I'll revisit other apps.

Artix-OpenRC with it's  3 minute installation is amazing.
It feels like I've been using dban with 13 hours for 3 passes, only to discover the 'secure erase command' and shred it all in 80 minutes.
 8)

Re: [Solved] CP Errors when Backing Up /var/cache/pacman/pkg

Reply #14

[quote ]
I don't think I'm interested in 'rsync' at this time.
[/quote]

that is a failure on your part and it reinforces the reluctance people have to help you.  The rest of what you wrote is static.

BTW - grip is right.  If you want to back up those file, and I don't know why you would do so,  you can't copy them  on to a VFAT file system so you need to learn something as simple as the mkfs.ext4 command and join the rest of us into the late 20th century.  Although your best solution might be to make a tarball which will contain all the file permission and ownership information.